Error message

Deprecated function: Array and string offset access syntax with curly braces is deprecated in include_once() (line 20 of /home/emun/public_html/includes/file.phar.inc).

jQuery quickie for zebra highlighting in tables

Tue, 11/14/2017 - 11:41 -- admin
jQuery

If you haven't taken the time to check out this framework you absolutely must do so now. jQuery allows you to accomplish so much more with so much little. It may be a little arcane to look at the first time, but after a little research, you'll wonder how you lived without it. Case in point, here's a quick script to add zebra highlighting to a table with id 'myTable'.

// Do zebra highlighting $("#myTableID tr:even").addClass('altrow');

This code can be added to an existing page and automagically apply the styles necessary. (You'll still have to define the style in your css)

While you can do something similar using just CSS using the :even pseudoselector, it is not as universally supported. And jQuery will allow you to do far more than simply alternate table colors.