- 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 get the children of $(this) selector?
To get the children of the $(this) selector in jQuery, use the find() method with each() method. Let us first see how to add jQuery:
Example
You can try to run the following code to get the children of the $(this) selector:
<html> <head> <title>jQuery Example</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> // Set the click handler on your div $("body").off("click", "#mydiv").on("click", "#mydiv", function() { // Find the image using.find() and .each() $(this).find("img").each(function() { var img = this; }); }); </script> <style> #mydiv { vertical-align: middle; background-color: #Ffff76; cursor: pointer; padding: 20px; } </style> </head> <body> <div id="mydiv"> <img src="/green/images/logo.png" width="300" height="100"/> </div> </body> </html>
- Related Articles
- How to get the children of the $(this) selector in jQuery?
- How to get a DOM Element from a jQuery Selector?
- How to get all children of a process using Process API in Java 9?
- How to teach children the value of money?
- How to get the number of siblings of this node in a JTree?
- How to get a set of elements containing all of the unique immediate children of each of the matched set of elements?
- Is it possible to use $(this) and universal selector (*) with jQuery?
- What makes children get attracted towards particular colors?
- There is a DB2 view VIEW1. How to get the definition of this view?
- Role of CSS :not (selector) Selector
- How to deal with stubborn children?
- How to get beginning of the first day of this week from timestamp in Android sqlite?
- Get the ID of this timezone in Java
- How to combine a class selector and an attribute selector with jQuery?
- Java Program to get the number of hours in this duration

Advertisements