The :parent selector in jQuery is used to select all elements that are the parent of another element, including text nodes.
Syntax:
$(":parent")
Example:
<!DOCTYPE html> <html> <head> <title> jQuery :parent() Selector </title> <script src= </script> <script> $(document).ready(function() { $("li:parent").css( "background-color", "green"); }); </script> </head> <body> <center> <h1 id="geeks1"> GeeksForGeeks</h1> <h2 id="geeks2"> jQuery :parent() Selector </h2> <div> <li>Geek1</li> <li></li> <li>Geek3</li> <li>Geek4</li> <li></li> <li>Geek6</li> </div> </center> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by jQuery :parent Selector are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- jQuery | parent > child Selector
- jQuery | parent descendant Selector
- SASS | Parent Selector
- How to find the parent class name with known class in jQuery ?
- JQuery | Get the n-th level parent of an element
- How to remove parent element except its child element using jQuery ?
- How to get position of an element relative to the document or parent 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 contribute@geeksforgeeks.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.

