Gets whether the checked value of input is true:
First type:
if ($ ("Input[name=item][value= ' Val ']"). attr (' checked ') ==true)//judge whether it has been ticked-note: name is the control Name property, value is the control Value property
The second type:
You can specify no property value, because the value value of a set of checkbox saves its corresponding ID in the database, preferably written as follows:
if ($ ("Input[name=row_checkbox]"). attr (' checked ') ==true)
The third type:
if ($ ("[Name=row_checkbox]"). attr (' checked ') ==true)--Note: name is the control Name property
jquery radio values, checkbox values, select values, Radio selected, CheckBox selected, select selected, and related articles Category: Web front-end:
Radio
Gets the value of a set of radio selected items: var item = $ (' input[name=items][checked] '). Val (); --Note: name is the control Name property
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");
Radio sets the value=2 element to the current selected item: $ ("Input[type=radio]"). attr ("Checked", ' 2′ ');
Radio the value of the selected item: $ ("input[name= ' Radio_name '][checked]"). Val ();
Set Radio to selected based on value: $ ("input[name= ' radio_name '][value= ' to select Radio Value '"). attr ("Checked", true);
Select
Gets the text of the Select selected item: var item = $ ("select[@name =items] option[@selected]"). Text ();
or var item = $ ("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; --Note: select_id ' is the ID property of the control
Select Drop-down Box value = ' val ' element is currently selected: $ ("Select[name=items] option[value= ' val '"). attr ("Selected", "Selected");
The select Setting Value=-sel3 items is currently selected: $ ("#sel"). attr ("value", '-sel3′ '); --Note: The SEL is the id attribute of the Select control
Add option:$ ("<option value= ' 1′>1111</option><option value= ' 2′>2222</option>") to the Drop-down box. Appendto ("#sel");
Select Empty: $ ("#sel"). empty ();
CheckBox
The second element of the checkbox is ticked: $ ("Input[name=items]"). Get (1). checked = true; Tick mark
CheckBox's value= ' val ' element tick: $ ("Input[name=item][value= ' Val ']"). attr ("Checked", true);
or $ ("Input[name=item][value= ' Val ']"). attr ("Checked", "checked");
Determine if the checkbox has been ticked: if ($ ("Input[name=item][value= ' Val ']"). attr (' checked ') ==true)
jquery Gets the value of the checkbox selection:
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's Checked Property:
$ ("#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)
According to the above three, analyze the meaning of this code:
$ ("Input[name= ' Checkbox_name ']"). attr ("Checked", $ ("#checkbox_id"). attr ("checked"));
--Note: Assign the same checked status to the input name= ' Checkbox_name ' based on the checked state of the control checkbox_id
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 ();
text box, text area: $ ("#txt"). attr ("value", "); Empty content
$ ("#txt"). attr ("value", ' 11′ '); Fill content
Event:
Triggered when object text_id gets focus: $ ("#text_id"). Focusing (function () {//code ...});
triggered when object text_id loses focus: $ ("#text_id"). blur (function () {//code ...});
Other:
Makes the Vlaue value of the text box selected: $ ("#text_id"). Select ();
$ ("#text_id"). Val (). Split (","); Returns the value of text to ', ' separated by an array
The above jquery to obtain a variety of input values of the simple implementation of the small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.