I reference the hidden field like:
var h = document.getElementById('myHiddenField');
How can I set the value to 100, and then output the value using a simple alert();?
The <input type="hidden"> defines a hidden input field.
How do you toggle a hidden field's true/false value using jquery? $('#myDiv'). on('click'), (function() { var hiddenField = $('#myHiddenField'), val = hiddenField. val(); hiddenField.
In jQuery to set a hidden field value, we use . val() method. The jQuery . val() method is used to get or set the values of form elements such as input, select, textarea.
var h = document.getElementById('myHiddenField');
h.value = 100;
alert(h.value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With