0

我是一个完整的 JQuery 初学者,我无法自由地找到答案似乎有点傻。

我试图从 JQuery 网站下载基本的 JQuery 库。但是,所有文件都将我引导到一个网站:http ://code.jquery.com/jquery-1.10.2.min.js ,它给了我大量的代码。

我应该将此代码放在记事本文件中并将其标记为 jquery-1.10.2.min.js 吗?

4

3 回答 3

1

复制所有代码并保存为 1.10.2.min.js..

将它放在根文件夹下的任何文件夹中,比如说 root/js/1.10.2.min.js

其中 i.10.2.min.js 是创建的文件的名称。

然后在脚本页面的 head 标签下编写此代码

<script src="root/js/1.10.2.min.js"></script>
于 2013-09-21T15:13:33.363 回答
1

You can save the script to a directory on your site. Then in your html header you can include the script. like so:

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

This way users will get the script from your site and you will be responsible for updating it as jquery changes.

Alternatively you can let someone else host it, like google. This way when jquery changes and google updates the script your site gets the new jquery features. Also users don't have to download from your site, and there's a better chance they'll have it cached.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>

You can also read up on why you should let a site like google host jquery at: http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/

于 2013-09-21T15:16:33.247 回答
0

您可以只包含此代码作为链接;

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js">
</script>
于 2013-09-21T15:13:35.153 回答