admin管理员组文章数量:1271802
Which html element should I use when using a Label for text?
I need to set the text of the element to a client name that is selected from an jqueryui autoplete control.
I've tried using a span, which works in Chrome but not in IE. Is there a remended way of doing this?
html:
<p>
<label for="ClientLabel">Client:</label>
<span id="ClientLabel" style="width: 160px; font-weight: bold;" />
</p>
autoplete javascript:
$('#ClientSearchAutoplete').autoplete(
{
source: "/Report/ClientAutopleteJSON",
select: function (event, ui) {
$('#ClientLabel').text(ui.item.value);
$('#ClientLabel').val(ui.item.id);
}
});
Which html element should I use when using a Label for text?
I need to set the text of the element to a client name that is selected from an jqueryui autoplete control.
I've tried using a span, which works in Chrome but not in IE. Is there a remended way of doing this?
html:
<p>
<label for="ClientLabel">Client:</label>
<span id="ClientLabel" style="width: 160px; font-weight: bold;" />
</p>
autoplete javascript:
$('#ClientSearchAutoplete').autoplete(
{
source: "/Report/ClientAutopleteJSON",
select: function (event, ui) {
$('#ClientLabel').text(ui.item.value);
$('#ClientLabel').val(ui.item.id);
}
});
Share
Improve this question
asked Jan 4, 2012 at 7:52
woggleswoggles
7,44413 gold badges77 silver badges132 bronze badges
2 Answers
Reset to default 6Input with type text has a text value and a readonly
property. It will look like a input box which you may want to style so as not to confuse the user.
<input type="text" name="ClientName" value="YourValue" readonly="readonly" />
The .val() method is used to get the values of form elements such as input, select and textarea. You are trying to use val() on a span which obviously doesn't work.
Replace it with a readonly input or store the ID in another hidden input element.
本文标签: javascriptHTML label for read only textStack Overflow
版权声明:本文标题:javascript - HTML label for read only text - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741139607a2345977.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论