If I wanted to find an element on the page, I would use $(‘#Foo’);
Now, I have a scenario where my ‘this’ context is a jQuery element. I would like to find an element underneath ‘this.’
I am using:
$(this).find('#Foo');
I just wanted to make sure there wasn’t a cleaner way of expressing this. If I wasn’t in my this context, I might use something like $(‘#this #Foo’). It seems surprising that my jQuery selector query gets longer when I have an explicit reference to the ‘this’ jQuery element.
first off, since element ids are unique to the document, you don’t need to find one within the context of another element.. but for a nice syntax, I like
$(‘.foo’, this) which will find all children with class “foo”