安装jQuery? [英] Installing jQuery?
问题描述
为新手安装jQuery的过程是什么?
What is the procedure for installing jQuery for someone new to it?
推荐答案
在一分钟或更短的时间内启动并运行jQuery:
将其插入到HTML中(最常见的是插入头部,但也可以将其扔到end body标签之前):
Insert this into your HTML (most commonly in the head, but you can throw it before the end body tag too):
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
然后在您的jQuery元素之后放置一个脚本元素. DOM准备就绪后,这将向"hello"发出警报.
Then place a script element after your jQuery one. This would alert 'hello' after the DOM is ready.
<script>$(function() { alert('hello') });</script>
阅读文档 .
Read the documentation.
在本地使用jQuery:
感觉良好后,请尝试将jQuery本地下载到您的计算机上,然后从脚本文件进行链接.结构是这样的:
After you get a feel, try downloading jQuery locally to your computer, and link it from your script file. The structure is like so:
C:/web/index.html
C:/web/js/jquery.js
index.html:
<head>
<script src="js/jquery.js"></script>
<script>$(function() { alert('hi') })</script>
</head>
如果没有Internet/Wi-Fi,则可以利用离线保存的版本的优点.您还可以对jQuery源进行自定义编辑,然后随意进行修改.
You have the advantage of relying on your saved version offline if you don't have the Internet/Wi-Fi. You can also make custom edits to the jQuery source and modify it at will.
研究jQuery源[高级]
从以下位置下载未压缩的版本:
Download the uncompressed version from:
http://code.jquery.com/jquery-latest.js
获得一些JavaScript/DOM知识后,请尝试将其逐步分解.
After you've gained a bit of JavaScript/DOM knowledge try to take it apart step by step.
这篇关于安装jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!