Gets the value of the first option
$ (' #test Option:first '). Val ();
The value of the last option
$ (' #test option:last '). Val ();
Gets the value of the second option
$ (' #test option:eq (1) '). Val ();
Get the selected value
$ (' #test '). Val ();
$ (' #test option:selected '). Val ();
Set option with a value of 2 is selected
$ (' #test '). attr (' value ', ' 2 ');
Set the first option to select
$ (' #test option:last '). attr (' Selected ', ' selected ');
$ ("#test"). attr (' Value ', $ (' #test option:last '). Val ());
$ ("#test"). attr (' Value ', $ (' #test option '). EQ ($ (' #test option '). length-1). Val ());
Get the length of a Select
$ (' #test option '). length;
Add an option
$ ("#test"). Append ("<option value= ' 9 ' >ff</option>");
$ ("<option value= ' 9 ' >ff</option>"). Appendto ("#test");
Add addition to selected items
$ (' #test option:selected '). Remove ();
The specified item is selected
$ (' #test option:first '). Remove ();
The specified value is deleted
$ (' #test option '). each (function () {
if ($ (this). val () = = ' 5 ') {
$ (this). Remove ();
}
});
$ (' #test option[value=5] '). Remove ();