Query gets the SELECT element and selects the text and value:
Query gets the Select element and sets the text and value:
jquery add/remove option item for select Element:
$ ("#select_id"). Append ("<optionvalue= ' Value '>Text</option>"); Append an option (drop-down) $ ("#select_id") for select. prepend ("<optionvalue= ' 0 '>Please select</option>"); Insert an option (first Position) $ ("#select_id Option:last") for Select. remove (); Delete the index value in select maximum option (last) $ ("#select_id option[index= ' 0 ']"). Remove (); Delete option (first) $ ("#select_id option[value= ' 3 ')" with index value 0 in Select. remove (); Delete option $ ("#select_id option[text= ' 4") for value= ' 3 ' in Select. remove (); Remove option three class for text= ' 4 ' in select<Selectname= "thirdlevel"ID= "thirdlevel"onchange= "getfourthlevel ()"> <optionvalue= "0"ID= "thirdoption">Please select level Three category</option> </Select> </Div>level four classification:<Selectname= "fourthlevelid"ID= "fourthlevelid"> <optionvalue= "0"ID= "fourthoption">Please select level four category</option> </Select> </Div>if ($ ("#thirdLevel"). val ()!=0) {$ ("#thirdLevel option[value!=0]"). Remove ();} if ($ ("#fourthLevelId"). val ()!=0) { $ ("#fourthLevelId option[value!=0]"). Remove (); }//this Expression: If we want to select the third class when choosing: if there is data in class fourth, Delete if there is no data in class Fourth of the commodity as the default Value. After learning Ajax technology in the back, often use!
Get Select:
Gets the text selected by the Select:
$ ("#ddlRegType"). Find ("option:selected"). text ();
Gets the value selected by Select:
$ ("#ddlRegType"). Val ();
Gets the index selected by the Select:
$ ("#ddlRegType"). Get (0). selectedindex;
Set Select:
Set the index selected by select:
$ ("#ddlRegType"). Get (0). selectedindex=index;//index as index value
Set the value selected by Select:
Set the text selected by Select:
var count=$ ("#ddlRegType option"). length; for (var i=0;i<count break;}} $ ("#select_id Option[text
To set the Select option Entry:
$ ("#select_id"). Append ("<optionvalue= ' Value '>Text</option>"); Add an option $ ("#select_id"). prepend ("<optionvalue= ' 0 '>Please select</option>"); Insert an option $ ("#select_id Option:last") in Front. remove (); Remove the maximum index value for the option $ ("#select_id option[index= ' 0 ')". remove ();//delete the option $ ("#select_id option[value= ' 3 '") with index value of 0. Remove (); Remove the option $ ("#select_id option[text= ' 4") with a value of 3. Remove (); Delete option with a text value of 4
Clear Select:
$ ("#ddlRegType"). Empty ();
jquery Gets the Value:
Val ()
Text ()
Setting the value
Val (' set value here ')
jquery Gets the value of option and operates on option