在 jQuery 中
$('html head').length // 1
和
$('html').find('head').length // 1
和
$('html').find('head').filter('html head').length // 1
但是
$('html').find('html head').length // 0
为什么?
最佳答案
因为没有<html>
标签嵌套在 <html>
中标签
但是:
$('html').find('html, head').length // return 1 here coz comma means 'or'
关于javascript - 为什么 $.fn.find() 中的选择器不能引用超出当前 $ 范围的树?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16941621/