Web Development with jQuery®

(Elliott) #1

Filtering a Selection (^) ❘ 51


FIGURE 2-3


Example 2-3 packs several concepts together to provide a more realistic example of how you might


use jQuery’s traversal methods. Like all previous examples, you start with the DOMContentReady event.


$(document).ready(
function()
{

The fi rst thing you do when the document is ready is set up a variable to contain a reference to


today, which contains the element with the class name calendarToday.


var today = $('td.calendarToday');

This example uses all class names because the calendar concept is one in which you might expect to


have multiple months loaded into the same document at once.


http://www.it-ebooks.info

Free download pdf