1. dropdown box select:
Remove option
$ ("#ID option"). each (the function () {
if ($ (this). val () = =) {
$ (this). Remove ();
}
});
Add option
$ ("<option value= ' >ups ground</option>"). Appendto ($ ("#ID"));
Get the selected value of the dropdown menu
Remove the text
$ (' #testSelect option:selected ') from the Pull. Text ();
$ ("#testSelect"). Find (' option:selected '). Text ();
Document.all.objselect.options[document.all.objselect.selectedindex].text; JS Operation objselect for select name//to obtain the Drop-down value
$ ("#testSelect"). Val ();
JS Operation
document.getElementById (' Objselect '). value=2;
Document.all.objSelect.value;
Select the Drop-down box based on the value of option
$ (' #testSelect '). Val (' a ');d ocument.all.objSelect.value = Objitemvalue; JS Operation objselect for select name or Iddocument.getelementbyid (' sel '). Value=objitemvalue;
The second element of the Select Drop-down box is the currently selected value
$ (' #select_id ') [0].selectedindex = 1;
2, Radio Box Radio :
$ ("input[type=radio][checked]"). Val (); Gets the value of the selected item in the Radio box (note that there are no spaces in the middle)
$ (': radio[name= ' Radio ']:checked '). Val (); the second method
$ ("input[type=radio][value=2]" ). attr ("Checked", ' checked '); Sets the value=2 of the radio box to the selected state. (Note that there are no spaces in between)
$ (': radio[value= "2"]). attr (' checked ', ' checked ');
Radio the second element of a radio group is the currently selected value
$ ("Input[name= ' items ']"). Get (1). checked = true;
3, check box checkbox : (Other wording see above: Radio)
$ ("input[type= ' checkbox '][checked]"). Val (); Gets the value of the first item selected in the check box
$ ("#chk1"). attr ("Checked", "");//Do not tick
$ ("#chk2"). attr ("Checked", true);
//uncheck/Select All
$ ("#selectAll"). Bind (' click ', Function () {
var sa = $ (this). attr ("checked");
$ ("Input[name= ' sel[]"). each (function () {
this.checked=sa;
});
4, Input box inputs:
$ (': input[name= "keyword"]). Val ();//Get value based on name value
5 , text box textarea :
Fixed text box size:
<textarea name= "123" style= "Resize:none;" ></textarea>
Above this javascript jquery to form element Common operation detailed explanation is small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.