Chl*_*loe 5 javascript google-chrome
我在测试JQuery时看到了Chrome的自动完成建议,并看到$$并$x已定义它们。它们是什么,它们来自哪里?我看到了Chrome中使用的$ x变量是什么?但是什么$$呢?
> $
function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} jquery.js?body=1:62
> $$
function $$() { [Command Line API] }
> $x
function $x() { [Command Line API] }
Run Code Online (Sandbox Code Playgroud)
这是ogooglebar。
我也有同样的问题。从 Ast Derek 发布的链接来看,默认情况下存在以下对象:
$() is an alias for document.querySelector()
$$() is an alias for document.querySelectorAll()
Run Code Online (Sandbox Code Playgroud)
我检查了 Chrome 和 Firefox,这两个似乎都是如此。
当您链接 jQuery 时,$() 会被 jQuery 对象替换,但 $$() 仍然以其默认行为存在。对于刚接触所有这些东西的人来说相当令人困惑。