In my HTML I have:
<div>
<input type="hidden" id="field" value="-1"/>
</div>
In my jQuery I have:
var fieldInput = $("#field");
if(someBoolIsTrue)
fieldInput.value = 4;
After this JS executes, I go to print the value of the hidden field, and it tells me it's still -1. Am I using jQuery incorrectly here?!? Thanks in advance!
$("#field")is not the raw DOM node; it's a jQuery wrapper. Thus the DOM API (like the "value" property) is not directly available. You can get the DOM node out of it, or you can use jQuery APIs to do what you need.