Latest web development tutorials

jQuery installation

Adding jQuery page

There are several ways to add jQuery in a web page. You can use the following methods:

  • From jquery.com download the jQuery library
  • Loading jQuery from CDN, when you load jQuery from Google

Download jQuery

There are two versions of jQuery are available for download:

  • Production version - used for the actual site has been streamlined and downsized.
  • Development version - for testing and development (uncompressed, readable code)

These two versions are available from jquery.com download.

jQuery is a JavaScript library file, you can use the HTML <script> tag to reference it:

<Head>
<Script src = "jquery-1.10.2.min.js"> </ script>
</ Head>

Tip: Download files in the same directory as the page, you can use jQuery.

lampIf you're wondering why we did not use type = "text / javascript" in the <script> tag?

In HTML5, you do not do that. JavaScript is HTML5, and all modern browsers default scripting language!


alternative plan

If you do not want to download and store jQuery, it can also refer to it by CDN (Content Distribution Network).

Baidu, they shoot clouds, Sina, Google and Microsoft servers all have jQuery.

If your site is the user, it is recommended to use Baidu, they shoot clouds, Sina and other domestic CDN address, if you are an overseas site users can use Google and Microsoft.

Note: Examples of this site are used Baidu jQuery CDN library.

For from Baidu, they shoot clouds, Sina, Google or Microsoft cited jQuery, use one of the following codes:

This tutorial CDN:

<Head>
<Script src = "http://cdn.static.w3big.com/libs/jquery/1.10.2/jquery.min.js">
</ Script>
</ Head>

try it"

Baidu CDN:

<Head>
<Script src = "http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</ Script>
</ Head>

try it"

Shoot Cloud CDN:

<Head>
<Script src = "http://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js">
</ Script>
</ Head>

try it"

Sina CDN:

<Head>
<Script src = "http://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js">
</ Script>
</ Head>

try it"

Google CDN:

<Head>
<Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</ Script>
</ Head>

try it"

lampTo get the latest version available through Google CDN:

Is not recommended to use Google CDN to get the version of the product is very unstable because of Google in China.
If you observe what the Google URL - specifies the jQuery version (1.8.0) in the URL. If you want to use the latest version of jQuery, you can also delete a number from the end of the version string (for example, in this case 1.8), Google returns 1.8 series in the latest available version (1.8.0,1.8.1 etc.), or may be only the first number, then Google will return a series of the latest available version (from 1.1.0 to 1.9.9).

Microsoft CDN:

<Head>
<Script src = "http://ajax.htmlnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js">
</ Script>
</ Head>

try it"

lampUse Baidu, they shoot clouds, Sina, Google or Microsoft jQuery, there is a great advantage:

Many users access other sites, has grown from Baidu, they shoot clouds, Sina, Google or Microsoft load over jQuery. All of the results, when they visit your site, jQuery is loaded from the cache, thus reducing the load time. At the same time, most of the CDN can ensure that when a user requests a file thereto, will be away from the user's most recent response from the server, so you can also load faster.