Home  >  Article  >  Web Front-end  >  A large collection of jQuery operations on Select (collection)_jquery

A large collection of jQuery operations on Select (collection)_jquery

WBOY
WBOYOriginal
2016-05-16 17:06:431008browse

1.jQuery adds/removes the Option item of Select:
2.$("#select_id").append(""); //Add an Option (drop-down item) to Select
3.$("#select_id").prepend("

1.jQuery gets the Text and Value selected by Select:
2.$("#select_id").change(function(){//code.. .}); //Add an event for Select, which is triggered when one of the items is selected
3.var checkText=$("#select_id").find("option:selected").text(); //Get Select's Text
4.var checkValue=$("#select_id").val(); //Get Select's Value
5.var checkIndex=$("#select_id ").get(0 ).selectedIndex; //Get the index value of Select
6.var maxIndex=$("#select_id option:last").attr("index"); //Get the maximum index value of Select jQuery sets Select selection Text and Value:

Statement:
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