jquery notes:
Copy Code code as follows:
$ ("Input[name= ' Radio_name ']:checked"). Val ()
<input type= "Radio" value= "1" name= "Radio_name"/>1
<input type= "Radio" value= "2" name= "Radio_name"/>2
<input type= "Radio" value= "3" name= "Radio_name"/>3
Things on the web are too messy, and different versions of jquery may be written differently, and after searching and experimenting, the following is the jquery 1.3.2 version.
jquery radio values, checkbox values, select values, Radio selected, CheckBox selected, select selected, and related settings:
Gets the value of a set of radio selected items: var item = $ (' input[name=items][checked] '). Val ();
Gets the text of the Select selected item
var item = $ ("select[@name =items] option[@selected]"). Text ();
Gets the text of the Select selected item: var item = $ ("Select[name=items] option[selected]"). Text (); Or
$ ("Select[name=items]"). Find ("option:selected"). Text ();
The second element of the Select Drop-down box is the currently selected value: $ (' #select_id ') [0].selectedindex = 1;
Select Drop-down Box value = ' val ' element is currently selected: $ ("Select[name=items] option[value= ' val '"). attr ("Selected", "Selected");
The second element of the radio Radio Group is the current check: $ (' input[@name =items] '). Get (1). checked = true; or $ (' input[name=items] '). attr ("Checked", 1′);
The Radio value = ' val ' element is currently selected: $ (' input[name=items][value= ' Val ']). attr ("Checked", "checked");
Get Value:
text box, text area: $ ("#txt"). attr ("value");
Multiple-selection box checkbox:$ ("Input[name= ' checkbox ': Checked]"). each (function () {
var val = $ (this). Val ();
});
Radio Group Radio: $ ("input[type=radio][checked]"). Val ();
Value value of the dropdown box select: $ (' select '). val ();
Dropdown box Select the selected text value: $ ("select"). Find ("option:selected"). Text ();
Control form elements:
text box, text area: $ ("#txt"). attr ("value", "); Empty content
$ ("#txt"). attr ("value", ' 11′ '); Fill content
Multi-selection box checkbox:
The second element of the checkbox is ticked: $ ("Input[name=items]"). Get (1). checked = true; Tick mark
$ ("Input[name=items]"). Get (1). checked = false; No tick.
CheckBox's value= ' val ' element before tick: $ ("Input[name=item][value= ' Val ']"). attr ("Checked", true); or $ ("input[name=item][value= ' Val '] "). attr (" Checked "," checked ");
if ($ ("Input[name=item][value= ' Val ']"). attr (' checked ') ==true)//judge whether it has been ticked
Radio Group Radio: $ ("Input[type=radio]"). attr ("Checked", ' 2′);//Set value=2 project is currently selected
Dropdown box Select: $ ("#sel"). attr ("value", '-sel3′);//Set VALUE=-SEL3 item is currently selected
$ ("<option value= ' 1′>1111</option><option value= ' 2′>2222</option>"). AppendTo ("#sel")// Option to add a drop-down box
$ ("#sel"). empty ();//Empty Drop-down box
jquery Gets the value of the radio selection
Code $ ("Input[name= ' Radio_name '][checked]"). Val (); Select the value of the selected radio
$ ("#text_id"). focus (function () {//code ...}); Event is triggered when object text_id gets focus
$ ("#text_id"). blur (function () {//code ...}); Event is triggered when the object text_id loses focus
$ ("#text_id"). Select (); Make the Vlaue value of the text box selected
$ ("Input[name= ' radio_name '][value= ' to select Radio Value '").
attr ("Checked", true); Set Radio as selected based on value values
jquery Gets the value value of the checkbox selection
$ ("Input[name= ' Checkbox_name '][checked]"); Select a collection of selected checkbox elements if you want the value, you need to traverse the collection.
$ ($ ("Input[name= ' Checkbox_name '][checked]")).
each (function () {arrchk+=this.value + ', ';}); /Traverse the collection of selected checkbox elements to get value
$ ("#checkbox_id"). attr ("checked"); Gets the state of a checkbox (has not been selected, returns True/false)
$ ("#checkbox_id"). attr ("Checked", true); Sets the status of a checkbox to be checked (checked=true)
$ ("#checkbox_id"). attr ("checked", false); Set the status of a checkbox to unchecked (Checked=false)
$ ("Input[name= ' Checkbox_name ']"). attr
("Checked", $ ("#checkbox_id"). attr ("checked");//According to the 3,4,5, you can analyze the meaning of this code.
$ ("#text_id"). Val (). Split (","); Returns the value of text to ', ' separated by an array
The above operations, in fact, is the use of jquery selector, I hope you have a solid knowledge of the jquery selector.