get value of a hidden input code example

Example 1: get hidden field value in javascript

// HTML : 
<input type=hidden id="abcId" name="abcName" value="Wall Street! Money Never Sleep"/>
  
  // JAVASCRIPT :
   alert(document.getElementById('abcId').value);
   alert(document.formName.elements['abcName'].value);

Example 2: get value of hidden type field

<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());