1. Get the value of the input class: $ ("input"). val ();
2. Get the textarea class value: $ ("textarea"). val ();
3. Obtain the value of the select class: $ ("select"). val ();
When the form contains multiple input classes (or textarea class and select class), the preceding method is used to obtain an array. Of course, you can add IDs to these controls to take a specific control value, for example, $ ("input # myID"). val ().
The following describes the value methods of each control:
1. input type = "text" single line text input box and input type = "password" password input box
$ ("Input"). val (); 2. input type = "radio" single vertex
$ ("Input: checked"). val (); // use checked to obtain the value of the selected single vertex. 3. input type = "checkbox" check box (worth noting)
$ ("Input: checked"). each (function (index ){
$ ("# Result"). append ($ (this). val () + "");
});
// Because the selection result of the check box is usually greater than 1, the result is an array.
// Use the. each () method to extract the selected values one by one.
// The result is appended to the section with the ID "result". 4. input type = "submit" (Form submission button)
The value method is the same as that of a single text input box, but it has no practical significance.
5. textArea multi-line text input box
$ ("Textarea"). val (); 6. select drop-down box (single choice and multiple choice)
$ ("Select"). val ();
// Note: if it is a check, the result is a string with a comma (,), for example, "select one, select two ". Note:
The value of a form Element usually occurs after the form is not submitted. In jQuery, we can use the following statement to determine the value:
$ ("Form"). submit (function (){
$ ("Input"). val ();
}); To set a value for a form element, you only need to set the value as a passing parameter, for example: $ ("input"). val ("jb51.net ");