Home  >  Article  >  Web Front-end  >  JQuery study notes 01 First contact with JQuery_jquery

JQuery study notes 01 First contact with JQuery_jquery

WBOY
WBOYOriginal
2016-05-16 18:27:521091browse
1. Download
The 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
Copy code The code is as follows:













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”

Copy the code The code is as follows:
$(function() { alert("hello"); })


is equivalent to

Copy Code The code is as follows:
$(document).ready(function() { alert("hello"); })


It is also basically equivalent to

Copy code The code is as follows:
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)
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn