• support@answerspoint.com

$(this) selector and children?


I have a layout similar to this:

<div id="..."><img src="..."></div>

and would like to use a jQuery selector to select the child img inside the div on click.

To get the div, I've got this selector:


How can I get the child img using a selector?



The jQuery constructor accepts a 2nd parameter called context which can be used to override the context of the selection.

jQuery("img", this);

Which is the same as using .find() like this:


If the imgs you desire are only direct descendants of the clicked element, you can also use .children():

  • answered 8 years ago
  • G John


You could also use


which would return all imgs that are descendants of the div

  • answered 8 years ago
  • Sandy Hook

Your Answer

    Facebook Share        
  • asked 8 years ago
  • viewed 1922 times
  • active 8 years ago

Best Rated Questions