Consider a hiddenfield in the page HfId
<input type="hidden" id="HfId"/>
How to assign,clear and get value of a hidden field in jquery? ANy suggestion...
The Element Selector of jQuery is exactly designed for this. It allows you to select all elements which fit the given name, id or class:
$("a") // Get all a-elements
$("#id") // Get all elements with the id "id"
$(".class") // Get all elements with the class "class"
The visibility or other properties of the element does not interfere with that, as it is still present in the DOM of the document.
Fields have the overloaded function val()
, val($value)
which allows you to get and set the value of the field:
$val = $("#HfId").val(); // Get
$("#HfId").val(""); // Clear
$("#HfId").val($newVal); // Set
$("#HfId").val("pony");
var x = $("#HfId").val();
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