javascript - 为什么 $.fn.find() 中的选择器不能引用超出当前 $ 范围的树?

标签 javascript jquery jquery-selectors dom-traversal jquery-traversing

在 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/

相关文章:

javascript - 如何将 JavaScript 添加到 FPDF 中?

javascript - 具有最小网络流量的进度条

javascript - 如何显示来自文本字段的用户输入

javascript - :not() selector 的问题

javascript - jQuery 将更改事件绑定(bind)到几个 DIV 中的所有子项,但选定项除外

javascript - 当 "name"属性中包含 "[]"括号时,如何使用 jQuery 预选择单选组按钮?

javascript - 引用 javascript 对象

javascript - 如何在 JavaScript 的客户端代码中获取其他国家/地区的当前日期时间?

javascript - 未捕获的 URIError : URI malformed - jquery UI tabs on Windows

javascript - Wordpress - 检查 jquery 插件是否已注册