HTML and CSS Reference
In-Depth Information
Starting with jQuery
In order to use jQuery you must include the jQuery library in the HTML page. This can be
achieved by serving your own copy of the jQuery library, or by utilizing a hosted version
from a content delivery network (CDN), most notably Google.
//
As a general rule, for production deployment you should favour CDN hosted op-
tions. These tend to provide superior performance for users than hosting your own
copy. For development I generally prefer to download my own copy, since this
removed the need for a network connection to run the application.
If you wish to use the Google hosted version of jQuery, simply include it in the head of the
HTML file:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
In order to serve your own copy, download the latest version of jQuery from here:
http://jquery.com/download/
The examples in this topic are using 2.0.3, but any recent version will be compatible.
jQuery consists of a single JavaScript file that can be downloaded in either minimised or
non-minimalized form. The non-minimalized form is useful for debugging, but either ver-
sion will be appropriate. Once downloaded, save the file in a subdirectory of the main folder
(the one containing the HTML file) called scripts.
Your directory structure should now look like this:
Now add the following to the head section of the HTML file:
<script src="scripts/jquery-2.0.3.js"></script>
 
Search WWH ::




Custom Search