Using jQuery

To use jQuery in a web page, insert a <script> tag and set the tag’s src (Source) property to a jQuery file.

You can set the Source property to a Google-hosted jQuery file, or you can host your own copy of jQuery.

jQuery has evolved over several versions. In general you should use the most current version; however, you may need to use an earlier version, for example if you wish to use a plugin which requires an earlier version and is incompatible with the current version.

Google-hosted jQuery file

You can use Google-hosted jQuery for free. Copy the code below and paste into your web page.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

For other versions of jQuery, and other Google-hosted libraries, see Google Libraries API Developer’s Guide.

Host your own copy of the jQuery file

  • jquery.com
  • Click “Download” button
  • File name will be jquery-something.js — name varies with version of file
  • Save jQuery file in folder of your choice
  • Insert <script> tag into web page, set src to jQuery file
  • jQuery is now available