You can simply call the .find()
method:
var Parent = $('#parent'); Parent.click(function() { $(this).find('.child').hide(); });
If you only want to select immediate children, use the .children()
method .children()
:
Parent.click(function() { $(this).children('.child').hide(); });
People often use type syntax
$('.child', this);
and. This is not very convenient for me, since you write the "reverse" order. Anyway, this syntax is converted internally to the .find()
operator, so you actually save the call.
Ref . : . find (),. children ()
jAndy
source share