javascript - jQuery's val() is not working on a hidden field -
i have hidden field in page so:
<hidden id="tsdayschedule01" value="7.50"></hidden> when try access following code, alert returns blank:
alert($("#tsdayschedule01").val()); now when use attr("value") below, works without issue:
alert($("#tsdayschedule01").attr("value")); lastly, point out have other non-hidden text fields within page work without issue using val().
i have better understanding going on here. have explanation?
<hidden/> isn't valid html element. if you're wanting hidden input you'd use:
<input type="hidden" /> jquery's .val() method works on input, select , textarea elements. work you, change <hidden/> element to:
<input type="hidden" id="tsdayschedule01" value="7.50" />
Comments
Post a Comment