O'Reilly logo

Drupal 7 by David Mercer

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

jQuery Basics

How jQuery works can be split into two main parts and summed up as:

Note

Find elements; do something with them.

If some of the code in the coming section appears quite complex, remember the previous statement and it should help to simplify things.

Because different parts of a web page can be loaded up at different times, we need to wrap any jQuery statements inside the ready() function to cause the jQuery JavaScript to be executed only once the page is fully loaded this prevents the jQuery application from breaking, in the event it is run before everything (specifically, its target page element) is present:

jQuery(document).ready(function(){
// Your code here
});

Let's take a look at a simple jQuery statement to highlight the ...

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