JQuery is a method that operates on the text and value values of the select drop down box
- 2020-03-30 03:09:00
- OfStack
1. Jquery gets the text value of the currently selected select
Var checkText = $(" # slc1 "). The find (" option: selected "). The text ();
2. Jquery gets the value of the currently selected select
Var checkValue = $(" # slc1 "). Val ();
3. Jquery gets the index value of the currently selected select
Var index = $(" # slc1 "). The get (0). SelectedIndex;
4. Jquery sets the index value of 1 as the currently selected item
$(" # slc1 "). The get (0). SelectedIndex = 1;
5. Jquery sets the item with value 2 as the currently selected item
$(" # slc1 "). Val (2);
6, jquery set the text value to "ivy garden" for the currently selected item
$(" # slc1 option [text = 'green garden w] "). The attr (" selected ", true);
Append an option to the specified select drop-down box (append to the end)
$(" # slc2 "). Append (" "+ I +" ");
8. Insert an option for the select drop-down box (insert into the first position)
$("#slc2").prepend(" please select ");
9. Jquery removes the last option in the select drop-down box
$(" # slc2 option: last "). The remove ();
Var checkText = $(" # slc1 "). The find (" option: selected "). The text ();
2. Jquery gets the value of the currently selected select
Var checkValue = $(" # slc1 "). Val ();
3. Jquery gets the index value of the currently selected select
Var index = $(" # slc1 "). The get (0). SelectedIndex;
4. Jquery sets the index value of 1 as the currently selected item
$(" # slc1 "). The get (0). SelectedIndex = 1;
5. Jquery sets the item with value 2 as the currently selected item
$(" # slc1 "). Val (2);
6, jquery set the text value to "ivy garden" for the currently selected item
$(" # slc1 option [text = 'green garden w] "). The attr (" selected ", true);
Append an option to the specified select drop-down box (append to the end)
$(" # slc2 "). Append (" "+ I +" ");
8. Insert an option for the select drop-down box (insert into the first position)
$("#slc2").prepend(" please select ");
9. Jquery removes the last option in the select drop-down box
$(" # slc2 option: last "). The remove ();