This article mainly introduces jquery to select the operation of a detailed summary, the need for friends can come to the reference, I hope to help you
1.jQuery Add/Remove option for select: 2.$ ("#select_id"). Append ("<option value= ' value ' >text</ Option> "); Appends an option (Drop-down) 3.$ ("#select_id") to the Select. Prepend ("<option value= ' 0 ' > Please select </option>"); Inserts an option (first position) 4.$ ("#select_id option:last") for the Select. Remove (); Deletes the maximum index value option (the last) 5.$ ("#select_id option[index= ' 0 ')" in the Select. Remove (); Deletes the option (first) 6.$ ("#select_id option[value= ' 3") with an index value of 0 in the Select. Remove (); Deletes option 7.$ ("#select_id option[text= ']" of value= ' 3 in the Select). Remove (); Deletes the option 8.$ ("#select_id") of text= ' 4 in the Select. Empty (); Empty option
1.jQuery in Select to get the text and value selected by select: 2.$ ("#select_id"). Change (function () {//code ...}); //adds an event for a select that triggers 3.var checktext=$ ("#select_id") when one of the items is selected. Find ("option:selected"). Text (); //Get Select text 4.var checkvalue=$ ("#select_id"). Val (); //Gets the value 5.var checkindex=$ ("#select_id") of select selected. Get (0). SelectedIndex; //Get the index value of select selected 6.var maxindex=$ ("#select_id option:last"). attr ("index"); //Get Select Maximum index value jquery set Select selected text and value: