May 2017
Intermediate to advanced
448 pages
10h 10m
English
Earlier, we added a highlight class to all cells containing the text Henry. To instead style the cell next to each cell containing Henry, we can begin with the selector that we have already written and simply call the .next() method on the result:
$(() => { $('td:contains(Henry)') .next() .addClass('highlight'); });
The tables should now look like this:

The .next() method selects only the very next sibling element. To highlight all of the cells following the one containing Henry, we could use the .nextAll() method instead:
$(() => { $('td:contains(Henry)') .nextAll() .addClass('highlight'); });
Read now
Unlock full access