1. DownloadThe official website is
http://jquery.com/The official download address:
http://docs.jquery.com/Downloading_jQuery There are downloads of the current version and historical versions, which can be downloaded and deployed on your own server.
It also has the CDN (Content Delivery Network) address of GoogleMicrosoftjQuery. Due to the widespread use of jQuery, choose the CDN address. You can make full use of cache and the bandwidth and server resources of these Internet giants.
There are two versions available for download from the official website: Compressed (Minified version) and Uncompressed (Source version)
The former is about 70k smaller, less than half the size of the uncompressed version.
But the uncompressed version is easier to read the source code and debug
2. Installation
Installing jQuery is very simple. Just reference the js file you downloaded in the HTML
For example,
If you use CDN, directly quote
3. The first program
You can execute it after refreshing the page.
You may be a little uncomfortable with $ at first, but in fact you will get used to it after using it for a long time, and you will like its simplicity. If you really can’t bear it, “$” can also be replaced by “jQuery”
$(function() { alert("hello"); })
is equivalent to
$(document).ready(function() { alert("hello"); })
It is also basically equivalent to
document.onready = function() {alert("hello");}
That is to say, after the browser completely parses the document structure, it can execute the following statement.
The difference from document.onload is that onload not only needs to parse the document structure, but also waits for all content that needs to be loaded to be loaded (such as pictures, etc.)
Because of the frequent use of $(document).ready(fn) , so it can be simplified to $(fn)