Drop- down box :
1 //Gets the text of the selected item in the drop-down menu (note that there are spaces in the middle)2 varCC1 = $ (". FORMC select[@name = ' country '] option[@selected]"). text ();3 4 //get the value of the selected item in the drop-down menu5 varCC2 = $ ('. FORMC select[@name = "Country"] '). Val ();6 7 //Gets the id attribute value of the selected item in the drop-down menu8 varCC3 = $ ('. FORMC select[@name = ' country '] '). attr ("id");9 Ten //Empty drop-down box// One$ ("#select"). empty (); $ ("#select"). HTML ('); A - //option to add a drop-down box -$ ("<option value= ' 1 ' >1111</option>"). AppendTo ("#select")
Radio Box :
1 // get the value of the selected item in the Radio box (note that there are no spaces in the middle) 2 $ ("input[@type =radio][@checked]"). Val (); 3 4 // sets the value=2 of the radio box to the selected state. (note there is no space in the middle) 5 $ ("input[@type =radio][@value =2]"). attr ("Checked", ' checked ');
check box :
1 //gets the value of the check box for the first item selected2$ ("input[@type =checkbox][@checked]"). Val ();3 4 //Because the check box is generally selected more than one, you can loop the output5$ ("input[@type =checkbox][@checked]"). each (function(){6Alert ($ ( This). Val ());7 });8 9 //no tick .Ten$ ("#chk1"). attr ("Checked", "); One A //Tick -$ ("#chk2"). attr ("Checked",true); - the //To determine if a tick has been made - if($ ("#chk1"). attr (' checked ') ==undefined) {}
jquery's handling of drop-down boxes, radio boxes, and multi-box options