I have some elements in my document like:
<div class="checkbox-inline"><label><input id="mylabel" value="False" type="checkbox">mytext</label></div>
When I try to get the text using:
$("#mylabel").text();
I get an error that text() is not defined on that object. My ids are unique, so my object is in the 0: position in $("#mylabel")
but both of these return an empty string for the text:
$("#mylabel").first().text();
$("#mylabel")[0].text();
How can I get the text mytext
out of these elements? And how can I programmatically modify it?
I realize now that my problem is slightly different than what I thought it was. Please see: Modifying the text of a label that also contains an input (checkbox) for my follow-up question. Thanks!