Doing $(\"#someId\").val(\"newValue\")
doesn\'t change the DOM --
I can retrieve this value with $(\"#someId\").val()
, but the element in the DOM s
This
$("#someId").val("newValue")
will change the value of the input element.
This
$("#someId").attr("value","newValue")
will change the value of the value attribute.
The second may help if you want to write the element. So, for example:
$("#someId").val("newValue")
$("#someId").attr("value","newValue")
write($("#someId").parent())
-will result in the new value being rendered, whereas
$("#someId").val("newValue")
write($("#someId").parent())
-will just show the original value.