Skip to navigation


The set of tools used to allow modification and control of the DOM are a bit of mess because they differ across browsers, generally for historical reasons. To make your job easier, a number of libraries have been created that hide these differences, providing a more uniform way of interacting with the DOM. Often they also provide AJAX functionality, taking the burden of that complexity away from you.

jQuery is far and away the most popular DOM library and it is used on a huge number of websites.

jQuery has a very distinctive syntax, all based around the dollar symbol. Here’s some:

$('.btn').click(function () {
    // do something

This code attaches a click handler to all elements with a class of btn. This selector syntax is core to jQuery.

jQuery is added to a page by simply including it as a file using a script element. Download it from, or include it from a Content Delivery Network (CDN) such as CDNJS:

<script src=""></script>

In the following pages we’ll be taking a look at jQuery for selecting and manipulating elements, AJAX and at some of its other useful tricks.