![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery parent descendant Selector
The parent descendant selector in jQuery is used to select all elements that are descendants of a specified element.
Syntax
The syntax is as follows −
("parent descendant")
Example
Let us now see an example to implement the jQuery parent descendent selector −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div span").css("color", "red"); }); </script> <style> div { border:1px solid black; padding:10px; } </style> </head> <body> <h2>Demo Heading<h2> <div> <span>span outside p element<span> <p>This is demo text<p> </div><br> <div> <p>This is demo text<p> <p>This is demo text. <span>span inside p element.</span></p> <p>This is demo text.</p> </div> </body> </html>
Output
This will produce the following output −
Advertisements