To learn more, see our tips on writing great answers. How can I validate an email address in JavaScript? valueif an Element is Hidden Asking for help, clarification, or responding to other answers. Thanks for contributing an answer to Stack Overflow! tools or "View Source" functionality. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. As mentioned above, hidden inputs can be used anywhere that you want to include data the user can't see or edit along with the form when it's submitted to the server. I changed the whole code. value Also, we can use the jquery val () method inside the script to get or set the value of the text input field. How do I check if an element is hidden in jQuery? There is a text value property that can set and return the value of the value attribute of a text field. You could give your hidden field an id: and then when you want to assign its value: document.getElementById('myField').value = product(2, 3); Make sure that you are performing this assignment after the DOM has been fully loaded, for example in the If the element has an id attribute and if it has a value attribute then you can use value property. Example 1: The following example uses the inbuilt bind () method of jQuery. https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Writing_efficient_CSS, https://developers.google.com/speed/docs/best-practices/rendering?hl=it#UseEfficientCSSSelectors. My code is GPL licensed, can I issue a license to have my code be distributed in a specific MIT licensed project? Which browser are you using? Click on See Values. When the form is submitted in step 3, the ID is automatically sent back to the server with the record content. Hidden e.parentNode.children(n).value; //n is zero indexed here Fiddle You have to wrap in the input in a