当我们在chrome控制台中键入 $ 时,它将返回一个函数.我确定它不是jQuery的 $ .如果我想在控制台中使用jQuery,什么是在chrome控制台中以 $ 触发jQuery的最佳方法.
When we type $ in chrome console it returns a function. I am sure it's not jQuery's $. If I want to use jQuery in console, What is the best way to trigger jQuery in chrome console as $.
推荐答案$ 是 document.querySelector 的别名.同样, $$ ,它是 document.querySelectorAll 的别名.
$ is an alias for document.querySelector. In the same vein there is $$ which is an alias for document.querySelectorAll.
它是在命令行(控制台)api中定义的.
It is defined in the Command line (console) api.
命令行API包含用于执行常见任务的便捷功能的集合:选择和检查DOM元素,以可读格式显示数据,停止和启动事件探查器以及监视DOM事件.
The Command Line API contains a collection of convenience functions for performing common tasks: selecting and inspecting DOM elements, displaying data in readable format, stopping and starting the profiler, and monitoring DOM events.
如果您在页面上将 $ 定义为全局变量(也许使用jQuery),则将获得该全局变量,而不是内置的命令行.
If you have $ defined on the page as a global (perhaps by using jQuery), you'll get that global, not the command-line built-in.
还有其他在那里定义了方便的功能.
要运行jQuery,而无需将其包含在页面源代码中,则可能会找到 Chrome扩展方便使用,或者只需在控制台中复制粘贴jQuery源代码即可.
To run jQuery, without having it in the page source code, you may find Chrome extensions to be handy, or simply copy-paste the jQuery source code in the console.
更多推荐
什么是"$"在Chrome控制台中?
发布评论