Add jQuery to the web page
##There are many ways to add jQuery to the web page. You can use the following methods:
#Download jQuery
There are two versions of jQuery available for download:
The jQuery library is a JavaScript file that you can reference using the HTML <script> tag:
<head>
<script src="jquery-1.10.2 .min.js"></script></head>
Note: You can use jQuery by placing the downloaded file in the same directory of the web page.
alternative plan
If you don't want to download and store jQuery, you can also reference it through a CDN (Content Delivery Network).
The servers of Baidu, Youpaiyun, Sina, Google and Microsoft all have jQuery.
If your site users are domestic, it is recommended to use domestic CDN addresses such as Baidu, Youpaiyun, Sina, etc. If your site users are foreign, you can use Google and Microsoft.
Note: All examples on this site use Baidu jQuery CDN library.
<head><script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">< ;/script>
</head>
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); }); </script> </head> <body> <p>欢迎大家来到php.cn</p> <button id="hide">隐藏</button> <button id="show">显示</button> </body> </html>Next Section