The :selected selector is used to select option elements those are pre-selected.
Note: To retrieve only the check-boxes or radio buttons, use the :checked selector.
Below examples illustrate the :selected selector in jQuery:
Example 1: This example use CSS property to all pre-selected elements. The background-color of pre-selected element is red, which is changed by :selected selector.
Example 2:This example is similar to previous-one.
- How to get all selected checkboxes in an array using jQuery ?
- How to know which radio button is selected using jQuery?
- How to get selected text from a drop-down list using jQuery?
- How to change selected value of a drop-down list using jQuery?
- jQuery | :lt() Selector
- jQuery | * Selector
- jQuery | :contains() Selector
- jQuery | :even Selector
- jQuery | :first Selector
- jQuery | :gt() Selector
- jQuery | :has() Selector with example
- jQuery | :odd Selector
- jQuery | :last Selector
- jQuery | #id Selector
- jQuery | :not() Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.