O'Reilly logo

CoffeeScript Programming with jQuery, Rails, and Node.js by Michael Erasmus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using jQuery

Using jQuery in the browser is very simple; you just need to include the jQuery library in your HTML file. You can either download the latest version of jQuery from their site (http://docs.jquery.com/Downloading_jQuery) and reference that, or you can directly link to a Content Delivery Network (CDN) version of the library.

Following is an example of how you might do it. This snippet comes from the excellent HTML5 Boilerplate project (http://html5boilerplate.com/). Here we include the latest minified jQuery from a Google CDN, but we will also include a local version if including from the CDN fails.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="js/lib/jquery-1.7.2.min.js"><\/script>') ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required