(^54) ❘ CHAPTER 2 SELECTING AND FILTERING
the selection to the fi rst
fi rst child
var nextWeek = today.parent('tr').next('tr');
if (nextWeek.length)
{
tomorrow = nextWeek.children('td').eq(0);
}
}
When you have determined which element, if any, represents tomorrow, you check to see if you have
a selection, and if you do, you add the class name calendarTomorrow to that
if (tomorrow.length)
{
tomorrow.addClass('calendarTommorow');
}
The next exercise is to identify all days after today, which will represent later this week. That is
done by calling nextAll() on the selection representing today, which brings back a selection of
elements, all of which are siblings to the
var laterThisWeek = today.nextAll('td');
if (laterThisWeek.length)
{
If there is a selection of
calendarLaterThisWeek.
laterThisWeek.addClass('calendarLaterThisWeek');
}
Then, you do the same thing to identify
week. To identify those elements, you call prevAll() on today to select all
the
var earlierThisWeek = today.prevAll('td');
if (earlierThisWeek.length)
{
If there are
the class name calendarEarlierThisWeek.
earlierThisWeek.addClass('calendarEarlierThisWeek');
}
Finally, you identify all sibling elements of the
siblings() method, and those elements are all given the class name calendarThisWeek.
today.siblings('td')
http://www.it-ebooks.info