I need to create a hidden field on my page, store some value in it and read that value later.
If i create a regular text input and read its value using jquery, i get the correct value. But if i create a hidden input field,populate it with some text and read its value using jquery i get null.
example:
Suppose the following input text box contains the value “Foo”.
<input type="text" id="inputfield"> </input>
Now, if i do $("#inputfield").val(), i correctly get “Foo”
But, if i change the type to “hidden”, and set the value of field, using $("#inputfield").val("Foo") then try to read the value using $("#inputfield").val(), it returns “”.
Can someone please tell me why this happens and any way to fix this ?
Thank You.
The following worked as expected: