Like normal input fields, values from the hidden input field can be access using the element.val().

Following is the example on how to do that.

<input type="hidden" id="xyz" name="zyx" value="foo" />

// Using the ID

// More faster approach using the ID

val() function fetches the html value from the specific object and in this case it is the input field. The second approach i.e. $('input#xyz').val() is much more faster than the first one because it uses the ID along with the element tag.

We can also use the name attribute to fetch the value of a hidden variable but it is less efficient because there might be a two elements with same name.