Jquery obtains and sets single-choice, multi-choice boxes, and text boxes.
Obtains the value of a set of Radio selected items.
VaR item = $ ("input [@ name = items] [@ checked]"). Val ();
Obtain the text of the selected select item.
VaR item = $ ("select [@ name = items] Option [@ selected]"). Text ();
The second element in the select drop-down box is the selected value.
$ ("# Select_id") [0]. selectedindex = 1;
The second element of the radio Radio Group is the currently selected value.
$ ("Input [@ name = items]"). Get (1). Checked = true;
Get value:
Text Box, text area: $ ("# TXT"). ATTR ("value ");
Multiple choice box checkbox: $ ("# checkbox_id"). ATTR ("value ");
Radio Group radio: $ ("input [@ type = radio] [@ checked]"). Val ();
Drop-down box select: $ ("# Sel"). Val ();
Control form elements:
Text Box, text area: $ ("# TXT"). ATTR ("value", ""); // clear content
$ ("# TXT"). ATTR ("value", "11"); // fill in the content
Multiple choice box checkbox: $ ("# CHK1"). ATTR ("checked", ""); // do not check
$ ("# CHK2"). ATTR ("checked", true); // check
If ($ ("# CHK1"). ATTR ("checked") = undefined) // you can check whether the check has been completed.
Radio Group radio: $ ("input [@ type = radio]"). ATTR ("checked", "2"); // set the project with value = 2 to the selected one (error)
$ ("Input [@ name = radio_s] [@ value = 16]"). ATTR ("checked", true); (tested)
Drop-down box select:
$ ("# Sel"). ATTR ("value", "-sel3"); // set the value =-sel3 project to the currently selected item
$ ("11112222"). appendto ("# Sel") // Add the option in the drop-down box
$ ("# Sel"). Empty (); // clear the drop-down list
$ ("# Select1") [0]. Options (INDEX). Selected = true; // select the index option
$ ("# Select1") [0]. Options (3). Text // obtain the option value with the index of 3
Reprinted from: http://www.cnblogs.com/lonelyDog/archive/2012/03/30/2425001.html