jquery's Operations large collection of SELECT

Source: Internet
Author: User

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:     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.