- 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 the $(this) selector in jQuery?
To get the children of the $(this) selector, use the jQuery find() method. You can try to run the following code to get the children of the $(this) selector −
Example
<html> <head> <title>jQuery Example</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('#mydiv').click(function(){ alert($(this).find('img:last-child').attr('src')); }); }); </script> <style> #my_div { width: 200px; height: 200px; background-color: red; } </style> </head> <body> <div id='mydiv'> <img src='https://www.tutorialspoint.com/videotutorials/images/tutorial_library_home.jpg' width='200' height='200' alt='Tutorials Library'> <img src='https://www.tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg' width='200' height='200' alt='Video Tutorials'> </div> </body> </html>
- Related Articles
- How to get the children of $(this) selector?
- How to get a DOM Element from a jQuery Selector?
- How to use universal (*) selector in jQuery?
- Is it possible to use $(this) and universal selector (*) with jQuery?
- What is the difference between jQuery(selector) and $(selector)?
- How to write a jQuery selector for the label of a checkbox?
- How to use *= operator in jQuery attribute selector?
- How to escape square brackets in jQuery selector?
- jQuery children() method
- How to combine a class selector and an attribute selector with jQuery?
- jQuery :first-of-type Selector
- jQuery :last-of-type Selector
- jQuery :nth-of-type() Selector
- jQuery :only-of-type Selector
- jQuery :button Selector

Advertisements