I know that I can use $('img', this) to select all img elements in $(this).
In my current case I am trying to manipulate only DIRECT child images of $(this).
Is there a selector for that??
Answer: Use the jQuery find() Method 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.
The ("parent > child") selector selects all elements that are a direct child of the specified element.
The children() method returns all direct children of the selected element. The DOM tree: This method only traverse a single level down the DOM tree. To traverse down multiple levels (to return grandchildren or other descendants), use the find() method.
$(this).find('> img')
Read this
$(this).children('img');
See also: http://api.jquery.com/children/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With