This article mainly introduces the usage of the val () method in jQuery and analyzes the two common usage of the val () method in the form of examples, which has some reference value, for more information about how to use the val () method in jQuery, see the following example. Share it with you for your reference. The specific analysis is as follows:
This method sets or gets the value Attribute value of the matching element.
Only elements with the value attribute can use this method. For example, this method can be used for input elements, but not for p elements.
Usage:
Usage 1:
This method returns the value Attribute value of the First Matching Element without parameters.For example:
The Code is as follows:
$ ("Input"). val ()
The above code gets the value Attribute value of the first input element.
Instance code:
The Code is as follows:
Val () function-script house