jQuery 如何下载jQuery?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3939401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:23:10  来源:igfitidea点击:

How to download jQuery?

jquerydownload

提问by Justin Meltzer

I'm trying to download JQuery. When I click the minified version, I just get a bunch of code displayed in the browser. I don't actually download anything. What am I supposed to do? How do I download JQuery and do I need to put it where my other files are?

我正在尝试下载 JQuery。当我单击缩小版本时,我只会在浏览器中显示一堆代码。我实际上没有下载任何东西。我应该做些什么?我如何下载 JQuery,我是否需要将它放在我的其他文件所在的位置?

回答by Trufa

There are many ways you can get this to work

有很多方法可以让它发挥作用

(it is supposed to show you the code like that)

(它应该向您展示这样的代码)

You can copy all the code and save it as and jquery.js file and the call it like this:

您可以复制所有代码并将其另存为 jquery.js 文件,然后像这样调用它:

<script type="text/javascript" src="jquery.js"></script>

Or you could just call it like this:

或者你可以这样称呼它:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>

You can also link to it from many different places:

您还可以从许多不同的地方链接到它:

http://code.jquery.com/jquery-1.4.2.jsSource version

http://code.jquery.com/jquery-1.4.2.js源码版

Google Ajax API CDN

谷歌 Ajax API CDN

http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

Microsoft CDN

微软CDN

http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js

http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js

Read more here:

在此处阅读更多信息:

http://docs.jquery.com/Downloading_jQuery

http://docs.jquery.com/Downloading_jQuery

EDIT:

编辑:

If you want to download the code you can actually do it! right-click the checkbox for example: PRODUCTION (24KB, Minified and Gzipped) and choose save as (maybe you′ll need to add the .js extension) "Thanks to: Jason McCreary & deceze"

如果您想下载代码,您实际上可以做到!右键单击复选框,例如:PRODUCTION (24KB, Minified and Gzipped) 并选择另存为(也许您需要添加 .js 扩展名)“感谢:Jason McCreary & deceze”

EDIT:

编辑:

To clarify your comment, you should include the jQuery like this:

为了澄清您的评论,您应该像这样包含 jQuery:

<script type="text/javascript" src="jquery.js"></script>

and now work as usual:

现在照常工作:

<script type="text/javascript" src="any_other_file.js"></script>

or

或者

<script language="javascript" type="text/javascript">

your javascript here

</script>

回答by Shoban

Goto this page : http://docs.jquery.com/Downloading_jQuery

转到此页面:http: //docs.jquery.com/Downloading_jQuery

Right Click the download link and click "Save Link As" (FF) or "Save Target as" (IE) and save it in your preferred location.

右键单击下载链接,然后单击“链接另存为”(FF)或“目标另存为”(IE)并将其保存在您的首选位置。

回答by Qcom

You can also link to the following jQuery source from Google's server, I believe the term is Google CDN.

您还可以从 Google 的服务器链接到以下 jQuery 源代码,我相信该术语是 Google CDN。

This is handy if a user or visitor of your site has that file already cached, which there is a good chance it is, loading times will be increased! :)

如果您网站的用户或访问者已经缓存了该文件,这很方便,这很有可能会增加加载时间!:)

You could use the following code:

您可以使用以下代码:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

Place that code within the <head>tags of your page.

将该代码放在<head>页面的标签中。

Good luck! :)

祝你好运!:)

回答by Jason McCreary

Right click or command click the link and select "Save As.."

右键单击或命令单击链接并选择“另存为..”

Or just copy the minified code displayed in the browser and save it to your JavaScript file.

或者只是复制浏览器中显示的缩小代码并将其保存到您的 JavaScript 文件中。

Maybe I am over simplifying it... it's late ;)

也许我简化了它......已经晚了;)

回答by Cameron

To answer the second part of your question, you can put the jQuery source file anywhere you want, as long as it's accessible via a URL.

要回答问题的第二部分,您可以将 jQuery 源文件放在您想要的任何位置,只要它可以通过 URL 访问即可。

To include jQuery in your webpages, add the following code to the <head>of your HTML:

要在您的网页中包含 jQuery,请将以下代码添加到<head>您的 HTML 中:

<script src="http://www.example.com/path/to/jquery.js" type="text/javascript"></script>

You can also use Google's CDN, which hosts jQuery for all to use (free), for better performance:

您还可以使用Google 的 CDN,它托管 jQuery 供所有人使用(免费),以获得更好的性能:

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js" type="text/javascript"></script>

回答by Cameron

If on Ubuntu/Linux, navigate to your static/css/js folder... or wherever you want to save the file:

如果在 Ubuntu/Linux 上,导航到您的 static/css/js 文件夹...或您想要保存文件的任何位置:

wget https://code.jquery.com/jquery-3.3.1.js

The file is now in your current directory.

该文件现在位于您的当前目录中。