什么是"$"在Chrome控制台中? [英] What is "$" in Chrome console?

查看:81
本文介绍了什么是"$"在Chrome控制台中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在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.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控制台中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆