Jquery method to get the value in the hidden domain: 1. Use the "$("input:hidden")" statement to get the hidden domain node; 2. Use the val() method to get the value in the hidden domain, the syntax is " hidden domain node.val()".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Hidden fields
<input type="hidden" name="" value="">
Hidden fields are invisible to users on the page. The purpose of inserting hidden fields in the form is to collect or send information to facilitate the users. Used by programs that process forms. When the viewer clicks the send button to send the form, the hidden field information is also sent to the server.
How to get the value in the hidden field with jquery?
In jquery, you can use the val() method to get the value in the hidden field.
val() method returns or sets the value of the selected element.
The value of the element is set through the value attribute. This method is mostly used for input elements.
If this method does not set parameters, it returns the current value of the selected element.
Get value syntax:
$(selector).val()
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-1.10.2.min.js"> </script> <script type="text/javascript"> $(document).ready(function() { $("button").click(function() { var value = $("input:hidden").val(); alert(value); }); }); </script> </head> <body> <input type="text" value="hello" /><br><br> <input type="hidden" value="欢迎来到PHP中文网" /> <button>获取隐藏域的值</button> </body> </html>
Related video tutorial recommendation: jQuery tutorial(video)
The above is the detailed content of How to get the value in the hidden field with jquery. For more information, please follow other related articles on the PHP Chinese website!