JQ operation of the HTML select control
1. Determine if the value= "Paravalue" item exists in the SELECT option
$ ("#selectid option[@value = ' paravalue ']"). length>0
2. Add an item to the Select option
$ ("#selectid"). Append ("<option value=" >1111<option> ");
3. Remove an item from the Select option
$ ("#selectid"). Remove ("<option value= >1111<option>");
4. Modify the text of value= "Paravalue" in the Select option to "Paratext"
$ ("#selectid option:selected"). attr ("value", "Paravalue"). attr ("text", "Paratext");
5. Set the first item of text= "Paratext" in Select to be selected
$ ("#selectid option[@text = ' paratext ']"). attr ("Selected", "true")
6. Set the item of value= "Paravalue" in Select to select
$ ("#selectid option[@value = ' paravalue ']"). attr ("Selected", "true")
7. Set the first item in select to select
$ ("#selectid option"). EQ (0). attr (' selected ', ' true ');
8. Gets the value of the current selected item of select
$ ("#selectid"). Val ();
9. Gets the text of the current selected item of select
$ ("#selectid"). Text ();
10. Get the index of the current selected item of select
document.getElementById ("Select1"). SelectedIndex;
$ ("#selectid"). Get (0). SelectedIndex
11. Clear the Select item
$ ("#selectid"). empty ();
Note: the EQ () method
The EQ () method assigns a matching element set reduction value to one on index.
$ (' li '). EQ (2). CSS (' background-color ', ' red ');
The result of this call is that the red background is set for Item 3. Note that index is zero-based and is the location of the reference element in the JQuery object, not in the DOM tree.
JQ operation of the HTML select control