![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
How to get a set of elements containing all of the unique immediate children of each of the matched set of elements?
The children( [selector] ) method gets a set of elements containing all of the unique immediate children of each of the matched set of elements.
Example
You can try to run the following code to learn how to get a set of elements containing all of the unique immediate children of each of the matched set 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(){ $("div").children(".selected").addClass("blue"); }); </script> <style> .blue { color:blue; } </style> </head> <body> <div> <span>Hello</span> <p class = "selected">Hello Again</p> <div class = "selected">And Again</div> <p class = "biggest">And One Last Time</p> </div> </body> </html> <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