1. Select tag
(1) event onchange triggered when the index changes
(2) obtain the selected text in the SELECT statement:
$ ("# XXX"). Find ("option: Selected"). Text ();
(3) obtain the selected value of select:
$ ("# XXX"). Val ();
(4) set the index selected by the SELECT statement:
$ ("# Ddlregtype"). Get (0). selectedindex;
(5) set the selected value of select:
$ ("# Ddlregtype"). ATTR ("value", "normal");
$ ("# Ddlregtype"). Val ("normal ");
$ ("# Ddlregtype"). Get (0). value = value;
2. Input checkbox tag
Upload: <input id = "CHK1" name = "Chk" type = "checkbox" value = "1"/>
Preview: <input id = "CHK2" name = "Chk" type = "checkbox" value = "2"/>
Outgoing mail: <input id = "chk3" name = "Chk" type = "checkbox" value = "4"/>
Download: <input id = "chk4" name = "Chk" type = "checkbox" value = "8"/>
(1) set the default option:
$ ("# Chkupload"). ATTR ("checked", true );
(2) Select All
$ ("[Name = chk]: checkbox"). ATTR ("checked", true );
(3) invert Selection
$ ("[Name = chk]: checkbox"). Each (function (){
$ (This). ATTR ("checked ",! $ (This). ATTR ("checked "));
});
(4) obtain the selected value (multiple options ):
VaR STR = "";
// Cyclically selected checkbox
$ ('Input [name = "Chk"]: checked'). Each (function (){
STR + = $ (this). Val ();
});
Alert (STR );
(5) Determine whether the specified selection box is selected
$ ("# CHK1"). ATTR ("checked"); the returned value is true, not false.
3. Input Radio (single choice)
<Input id = "radio1" name = "R1" type = "radio" value = "1"/>
<Input id = "Radio2" name = "R1" type = "radio" value = "0"/>
(1) obtain the selected value
$('input[name="R1"]:checked').val();
(2) Obtain a specific radio value, such as the second one:
$('input[name="R1"]:eq(1)').val();
(3) traversal, same as the checkbox tag;
(4) assign values to select
$ ('Input [name = "R1"] [value = "1"] '). ATTR ("checked", true );