You can use the find() method to get the children of the $(this) selector using jQuery.
The jQuery code in the following example will simply select the child <img> element and apply some CSS style on it on click of the parent <div> element.
If you want to get only direct descendants of the target element, you can also use the children() method. The children() method only travels a single level down the DOM tree whereas the find() can traverse down multiple levels to select descendant elements (grandchildren, etc.).
Use the jQuery
find()MethodYou can use the
find()method to get the children of the$(this)selector using jQuery.The jQuery code in the following example will simply select the child
<img>element and apply some CSS style on it on click of the parent<div>element.If you want to get only direct descendants of the target element, you can also use the children() method. The children() method only travels a single level down the DOM tree whereas the find() can traverse down multiple levels to select descendant elements (grandchildren, etc.).
need an explanation for this answer? contact us directly to get an explanation for this answer