Get value from hidden field using jQuery
This should work:
var hv = $('#h_v').val();
alert(hv);
If you don't want to assign identifier to the hidden field; you can use name or class with selector like:
$('input[name=hiddenfieldname]').val();
or with assigned class:
$('input.hiddenfieldclass').val();
Use val()
instead of text()
var hv = $('#h_v').val();
alert(hv);
You had these problems:
- Single quotes was not closed
- You were using
text()
for an input field - You were echoing
x
rather than variablehv