用于在Google Chrome检查器上加载jQuery的命令? [英] Command for loading jQuery on Google Chrome inspector?
问题描述
我记得看到有一个特定的命令可以放在Google Chrome的检查器控制台上,用于加载jQuery并允许您执行jQuery命令。
然而,我不记得它是哪个命令,而在线搜索只会给我带来无关的结果。
任何人都知道哪个命令是?
谢谢!
编辑:多年后,我意识到我要求 $$
在控制台中的功能。但是,这不是jQuery,但提供了一个类似的选择器选项,很可能是 document.querySelectorAll
的简写。这里的答案提到了将jQuery添加到实际的功能中。
javascript:if(!window.jQuery || confirm(' ?Overwrite\x20current\x20version \x20v '+ jQuery.fn.jquery))(函数(d,S){S = d.createElement(' 脚本 '); s.src =' https://开头AJAX。 googleapis.com/ajax/libs/jquery/1.8/jquery.js';(d.head||d.documentElement).appendChild(s)})(document);
它检测jQuery是否存在。如果确实如此,则会出现一个确认对话框,其中显示当前版本,以便您可以决定是否可以重叠现有的jQuery对象。
目前,jQuery 1.8通过SSL从CDN加载。
- 如果你想加载一个不同的版本,把
'1.8'
与例如'1.7.1'
。 - 如果要加载压缩版本,请替换
jquery.js
与jquery.min.js
。 - 如果您不介意加载
http:
,Google的CDN可以替换为:
为了节省编辑时间,这里有与答案顶部相同的小书签,但要获取最新版本 strong>(而不是固定的)
JavaScript的:如果(window.jQuery ||确认( '?Overwrite\x20current\x20version \x20v' + jQuery.fn .jquery))(函数(d,S){S = d.createElement( '脚本'); s.src =的 'http://code.jquery.com/jquery.js';(d.head || d .documentElement).appendChild(S)})(文件);
注意:拥有最新版本不错,但当jQuery行为怪异时不要感到惊讶。 (=已更新)。
I remember seeing that there was a specific command you could put on Google Chrome's inspector console for it to load jQuery and allow you to execute jQuery commands.
However, I cannot remember which command it was, and searching online only brings me unrelated results.
Anyone knows which is that command?
Thanks!
EDIT: Years later I had realized that I was asking for the $$
function in the console. However, this is not jQuery but provides a similar selector option, most likely a shorthand for document.querySelectorAll
. The answers here address adding jQuery for real, with all of its functionality.
You mean, a script to load jQuery in an arbitrary page? I have constructed the following cross-browser bookmarklet for this purpose:
javascript:if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js';(d.head||d.documentElement).appendChild(s)})(document);
It detects whether jQuery exists. If it does, a confirmation dialog appears, in which the current version is shown, so that you can decide whether it's OK to overwtite the existing jQuery object.
Currently, jQuery 1.8 is loaded from a CDN over SSL.
- If you want to load a different version, replace
'1.8'
with e.g.'1.7.1'
. - If you want to load a compressed version, replace
jquery.js
withjquery.min.js
. - If you don't mind loading jQuery over
http:
, Google's CDN can be replaced with:- http://code.jquery.com/jquery.js - Latest version
- http://code.jquery.com/jquery-latest.js - Latest version
- http://code.jquery.com/jquery-1.8.0.js - Version 1.8
To save you time from editing, here's the same bookmarklet as the top of the answer, but getting the latest version (instead of a fixed one) from http://code.jquery.com/
:
javascript:if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='http://code.jquery.com/jquery.js';(d.head||d.documentElement).appendChild(s)})(document);
Note: Having the latest version is nice, but don't be surprised when jQuery "behaves weird" (=updated).
这篇关于用于在Google Chrome检查器上加载jQuery的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!