I am using JQuery 1.8.3. I have below HTML label.
<label for="myalue" style="vertical-align: middle"></label>
Now using JQuery i need to set a string to above label and am trying as below.
$("label[for='myalue']").text("someText");
Above code works only in IE. But in Firefox label value is not set.
Any suggestions?
Thanks!
You should be able to use
$("label[for='myalue']").html("someText");
or
$("label[for='myalue']").text("someText");
The only difference between html & text is that:
html() get/set HTML of an element
text() get/set innertext of an element
In you case I would use text() as it should be faster (at least looking at the jquery code). I've just tested both of this functions in chrome, IE9 and firefox and they work fine with label tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With