$ ("#select_id").change(function(){//code...}); //Add an event for Select, which is triggered when one of the items is selected var checkText=$("#select_id"). find("option:selected").text(); //Get the Text selected by Select var checkValue=$("#select_id").val(); //Get the Value selected by Select var checkIndex =$("#select_id ").get(0).selectedIndex; //Get the index value selected by Select var maxIndex=$("#select_id option:last").attr("index"); // Get the maximum index value of Select $("#select_id ").get(0).selectedIndex=1; //Set the item with Select index value to 1 to select $("#select_id ").val( 4); //Set the value of Select to 4 and select the item $("#select_id option[text='jQuery']").attr("selected", true); //Set the Text value of Select Select
$("#select_id").append(""); //Insert an Option for Select (the first position) $("#select_id option:last").remove(); //Remove the Option with the largest index value in Select (the last one) $(" #select_id option[index='0']").remove(); //Delete the Option with index value 0 in Select (the first one) $("#select_id option[value='3']" ).remove(); //Delete Option with Value='3' in Select $("#select_id option[text='4']").remove(); //Delete Text='4 in Select 'Option
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn