jQuery 库能够经过一行简单的标记被添加到网页中。javascript
jQuery 是一个 JavaScript 函数库。html
jQuery 库包含如下特性:java
jQuery 库位于一个 JavaScript 文件中,其中包含了全部的 jQuery 函数。jquery
能够经过下面的标记把 jQuery 添加到网页中:ajax
<head> <script type="text/javascript" src="jquery.js"></script> </head>
请注意,<script> 标签应该位于页面的 <head> 部分。api
下面的例子演示了 jQuery 的 hide() 函数,隐藏了 HTML 文档中全部的 <p> 元素。ide
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button type="button">Click me</button> </body> </html>
共有两个版本的 jQuery 可供下载:一份是精简过的,另外一份是未压缩的(供调试或阅读)。函数
这两个版本均可从 jQuery.com 下载。动画
Google 和 Microsoft 对 jQuery 的支持都很好。google
若是您不肯意在本身的计算机上存放 jQuery 库,那么能够从 Google 或 Microsoft 加载 CDN jQuery 核心文件。
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs
/jquery/1.4.0/jquery.min.js"></script>
</head>
<head>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
</head>