两者之间有什么区别吗:
var a = $('.a');
$('.b', a).click(function(){
});
和:
a.find('.b').click(function(){
});
?
最佳答案
第一个jQuery( selector [, context ] )将上下文转换为第二个由jQuery调用find
的上下文。我更喜欢第二个。
Internally, selector context is implemented with the .find() method, so $( "span", this ) is equivalent to $( this ).find( "span" ), jQuery Docs
关于javascript - 选择后代元素的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22236129/