用于在Google Chrome检查器上加载jQuery的命令? [英] Command for loading jQuery on Google Chrome inspector?

查看:121
本文介绍了用于在Google Chrome检查器上加载jQuery的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记得看到有一个特定的命令可以放在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加载。



为了节省编辑时间,这里有与答案顶部相同的小书签,但要获取最新版本 strong>(而不是固定的) http://code.jquery.com/ :

  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.

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屋!

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