Reputation: 11545
Is there any difference between:
var a = $('.a');
$('.b', a).click(function(){
});
and:
a.find('.b').click(function(){
});
?
Upvotes: 0
Views: 81
Reputation: 148120
The first one jQuery( selector [, context ] ) that takes context is converted to second one which calls find
by the jQuery. I would prefer second one.
Internally, selector context is implemented with the .find() method, so $( "span", this ) is equivalent to $( this ).find( "span" ), jQuery Docs
Upvotes: 6