- Trending Categories
- 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
How to locate all the descendant elements of a particular type of element?
The find( selector ) method can be used to locate all the descendant elements of a particular type of elements. The selector can be written using any selector syntax.
Example
You can try to run the following code to learn how to locate all the descendant elements of a particular type of elements:
<html> <head> <title>jQuery Example</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function() { $("p").find("span").addClass("selected"); }); </script> <style> .selected { color:blue; } </style> </head> <body> <p>This is first paragraph and <span>THIS IS BLUE</span></p> <p>This is second paragraph and <span>THIS IS ALSO BLUE</span></p> </body> </html>
Advertisements