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 change selected value of a drop-down list 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 get all selected checkboxes in an array using jQuery ?
- How to get file input by selected file name without path using jQuery ?
- How to reset selected value to default using jQuery ?
- How to show contents of selected row of a table in Bootstrap model using jQuery ?
- jQuery | :input Selector
- jQuery | :nth-of-type() Selector
- jQuery | :enabled Selector
- jQuery | element Selector
- jQuery | :last Selector
- jQuery | :button Selector
- jQuery | animated Selector with Example
- jQuery | :header Selector
- jQuery | #id Selector
- jQuery | .class Selector
- jQuery | :text Selector
- jQuery | :password Selector
- jQuery | :file 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 email@example.com. 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.