JQuery learning notes 01 JQuery First Contact

Source: Internet
Author: User
Tags jquery cdn

1. Download
Official website is http://jquery.com/
Http://docs.jquery.com/Downloading_jQuery
You can download the current and historical versions and deploy them on your own server.
The Google \ Microsoft \ jQuery CDN (Content Delivery Network) address is also listed above. Because jQuery is widely used, you can select a CDN address to make full use of the cache and the bandwidth and server resources of these Internet giants.
The official website contains two versions: Compressed (Minified version) and Uncompressed (Source version)
The size of the former is about 70 KB and less than half the size of the uncompressed version.
However, uncompressed versions make it easier to read the source code and debug it.
Ii. Installation
It is very easy to install jQuery. You only need to reference the js file you downloaded in HTML.
For example, <script type = "text/javascript" src = "/jslibs/jquery. min. js"> </script>
Directly reference <script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
3. The first program
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
<Script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
<Script type = "text/javascript">
$ (Function () {alert ("hello ");})
</Script>
</Head>
<Body>
</Body>
</Html>


After refreshing the page, you can execute it.
At the beginning, it may be a little uncomfortable with $. In fact, it will take a long time to get used to it and like its conciseness. If you cannot afford it, you can replace "$" with "jQuery ".

Copy codeThe Code is as follows: $ (function () {alert ("hello ");})


Equivalent

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


It is also basically equivalent

Copy codeThe 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 between onload and document. onload is that onload not only needs to parse the document structure, but also waits until all the content to be loaded is loaded (such as parts)
Because $ (document). ready (fn) is frequently used, it can be simplified to $ (fn)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.