我在没有 jQuery 的页面上使用 google chrome 的开发人员工具(或使用 $
符号作为快捷方式的任何其他库)。当我通过控制台检查 $
时(只需输入并按回车),我得到了这个:
$
function () { [native code] }
因此,chrome 有一些本机功能,可以通过 $
引用。只有 chrome 似乎有这个,我无法通过 window['$']
或通过 document['$']
或 this['$']
访问它。
我无法找出这个功能是什么。您知道它的作用吗?也许对此有一些背景信息?提前致谢!
原文由 Dennis 发布,翻译遵循 CC BY-SA 4.0 许可协议
即使从去年开始,情况又发生了变化。
devtools 控制台提供
$
作为document.querySelector
的别名,以及 许多其他东西;这是一个摘录列表:…和其他一些。
Note how it calls
$
an alias ofdocument.querySelector
, but says$$
is “equivalent” to callingdocument.querySelectorAll
.两者似乎都不是真的。$ === document.querySelector
ISNodeList
ISfalse
和$$