I'd like to use a selector to select the child img of the div I'm clicking on this example:
<div id="..."><img src="..."></div>
To get the div, I've got this selector:
$(this)
How do I get the img with a selector?
I'd like to use a selector to select the child img of the div I'm clicking on this example:
<div id="..."><img src="..."></div>
To get the div, I've got this selector:
$(this)
How do I get the img with a selector?
Without knowing the ID of the DIV I think you could select the IMG like this:
$("#"+$(this).attr("id")+" img:first")
Thanks maxam, I've found it with your start :)
jQuery(this).children("img")
You could also use
$(this).find('img');
which would return all img
s that are descendants of the div
The jQuery constructor accepts a 2nd parameter which can be used to override the context of the selection.
jQuery("img", this);