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

Bar*_*ney 1 javascript jquery jquery-selectors dom-traversal jquery-traversing

在jQuery中

$('html head').length                             // 1
Run Code Online (Sandbox Code Playgroud)

$('html').find('head').length                     // 1
Run Code Online (Sandbox Code Playgroud)

$('html').find('head').filter('html head').length // 1
Run Code Online (Sandbox Code Playgroud)

$('html').find('html head').length                // 0
Run Code Online (Sandbox Code Playgroud)

为什么?

A. *_*lff 7

因为<html>标签内没有嵌套<html>标签

但:

$('html').find('html, head').length // return 1 here coz comma means 'or'
Run Code Online (Sandbox Code Playgroud)


tym*_*eJV 5

根据文件:

查找:获取当前匹配元素集中每个元素的后代,由选择器,jQuery对象或元素过滤.

HTML 不是的后代 HTML

http://api.jquery.com/find/