jQuery access input hidden value

javascript, jquery

Solution

You can access hidden fields' values with `val()`, just like you can do on any other input element:

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

alert($('input#foo').val());
alert($('input[name=zyx]').val());
alert($('input[type=hidden]').val());
alert($(':hidden#foo').val());
alert($('input:hidden[name=zyx]').val());

Those all mean the same thing in this example.

Problem

How can I access `<input type="hidden">` tag's `value` attribute using jQuery?

Original source

Related problems