jQuery Introduction
jQuery is a JavaScript library that greatly simplifies JavaScript programming. The jQuery library can be added to a web page with a single line of HTML markup.
jQuery Prerequisites
Before jumping into jQuery, it is helpful to have a basic knowledge of:
- HTML
- CSS (Cascading Style Sheets)
- JavaScript
There are Quick Guides for each of these subjects.
Adding jQuery to Web Pages
The jQuery library is contained in a single JavaScript file and can be added to a web page with the following mark-up:
<head>
<script src="jquery.js">
</script>
</head>
Obtaining the jQuery Library
The jQuery library can be downloaded from
jQuery.com
. It is available in two forms: minified (for production) and uncompressed (for debugging or development).
Once the library has been obtained, it can be hosted on a web server.
Using a hosted jQuery Library
A number of large enterprises provide hosted copies of jQuery on existing Content Delivery Networks (CDN) that are available for public use.
The following examples show how to code the HTML for to use a hosted library:
// jQuery CDN
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js">
</script>
</head>
// Google CDN
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
</head>
// Microsoft CDN
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js">
</script>
</head>
JQuery Name Conflicts
jQuery uses the $ sign as a shortcut for jQuery. This may conflict with other JavaScript libraries that also use the dollar sign for their functions.
The jQuery noConflict() method specifies a custom name (like jq), instead of using the dollar sign.
jQuery Statistics
- The jQuery project was started by John Resig in 2005
- First stable release was August 26, 2006
- Latest stable version is 1.9.1 (February 4, 2013)