May 2017
Intermediate to advanced
448 pages
10h 10m
English
Our advanced table striping now works nicely, but behaves strangely when the topic filter is used. For the two functions to play together well, we need to re-stripe the table each time a filter is used. We will also need to consider whether rows are currently hidden when calculating where to apply the alt class:
$(() => { function stripe() { $('#news') .find('tr.alt') .removeClass('alt') .end() .find('tbody') .each((i, element) => { $(element) .children(':visible') .has('td') .filter(i => (i % 4) < 2) .addClass('alt'); }); } stripe(); $('#topics a') .click((e) => { e.preventDefault(); const topic = $(e.target).text(); $(e.target) .addClass('selected') .siblings('.selected') .removeClass('selected'); $('#news ...Read now
Unlock full access