Add Option
$ ("# ID Option"). Each (function (){
If ($ (this). Val () = 111 ){
$ (This). Remove ();
}
});
Remove Option
$ ("<Option value = '000000'> ups ground </option>"). appendto ($ ("# ID "));
Obtain the selected value from the drop-down list.
$ ("# Testselect option: Selected"). Text ();
$ ("# Testselect"). Find ('option: selected'). Text ();
$ ("# Testselect"). Val ();
Select the drop-down Box Based on the option value
$ ('# Testselect'). Val ('20140901 ');
2, single region:
$ ("Input [@ type = radio] [@ checked]"). Val (); // obtain the value of the selected item of a single sequence (note that there is no space in the middle)
$ ("Input [@ type = radio] [@ value = 2]"). ATTR ("checked", 'checked'); // set single checked value = 2 to the selected status. (Note that there is no space in the middle)
3. Check box:
$ ("Input [@ type = checkbox] [@ checked]"). Val (); // obtain the value of the first check box.
$ ("Input [@ type = checkbox] [@ checked]"). Each (function () {// Since multiple check boxes are selected, You can output them cyclically.
Alert ($ (this). Val ());
});
$ ("# CHK1"). ATTR ("checked", ''); // do not check
$ ("# CHK2"). ATTR ("checked", true); // check
If ($ ("# CHK1"). ATTR ('checked') = undefined) {}// you can check whether a check has been performed.
Of course, jquery's selector is powerful. There are many other methods.
<SCRIPT src = "jquery-1.2.1.js" type = "text/JavaScript"> </SCRIPT>
<Script language = "JavaScript" type = "text/JavaScript">
$ (Document). Ready (function (){
$ ("# Selecttest"). Change (function ()
{
Alert ($ ("# selecttest option [@ selected]"). Text ());
$ ("# Selecttest"). ATTR ("value", "2 ");
});
});
</SCRIPT>
<A href = "#"> aaass </a>
<! -- Drop-down box -->
<Select id = "selecttest" name = "selecttest">
<Option value = "1"> 11 </option>
<Option value = "2"> 22 </option>
<Option value = "3"> 33 </option>
<Option value = "4"> 44 </option>
<Option value = "5"> 55 </option>
<Option value = "6"> 66 </option>
</SELECT>
Jquery radio value, checkbox value, select value, Radio selected, checkbox selected, select selected, and related to obtain the value of a set of Radio selected items
Varitem = $ ('input [@ name = items] [@ checked] '). Val ();
Obtain the text of the selected select item.
Varitem = $ ("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 selection 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 the content
$ ("# TXT"). ATTR ("value", '11'); // fill in the content
Multiple selection box checkbox:
$ ("# CHK1"). ATTR ("checked", ''); // do not check
$ ("# CHK2"). ATTR ("checked", true); // check
If ($ ("# CHK1"). ATTR ('checked') = undefined) // you can check whether the checked has been checked.
Radio Group Radio:
$ ("Input [@ type = radio]"). ATTR ("checked", '2'); // set the project with value = 2 to the selected one
Drop-down box select:
$ ("# Sel"). ATTR ("value", '-sel3'); // set the value =-sel3 project to the currently selected item
$ ("<Optionvalue = '1'> 1111 </option> <optionvalue = '2'> 2222 </option> "). appendto ("# Sel") // Add the option in the drop-down box
$ ("# Sel"). Empty (); // clear the drop-down list
Obtains the value of a set of Radio selected items.
Varitem = $ ('input [@ name = items] [@ checked] '). Val ();
Obtain the text of the selected select item.
Varitem = $ ("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 selection 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 the content
$ ("# TXT"). ATTR ("value", '11'); // fill in the content
Multiple selection box checkbox:
$ ("# CHK1"). ATTR ("checked", ''); // do not check
$ ("# CHK2"). ATTR ("checked", true); // check
If ($ ("# CHK1"). ATTR ('checked') = undefined) // you can check whether the checked has been checked.
Radio Group Radio:
$ ("Input [@ type = radio]"). ATTR ("checked", '2'); // set the project with value = 2 to the selected one
Drop-down box select:
$ ("# Sel"). ATTR ("value", '-sel3'); // set the value =-sel3 project to the currently selected item
$ ("<Option value = '1'> 1111 </option> <option value = '2'> 2222 </option> "). appendto ("# Sel") // Add the option in the drop-down box
$ ("# Sel"). Empty (); // clear the drop-down list
Complete JQ select operations