Created
July 26, 2011 16:42
-
-
Save AdamTReineke/1107198 to your computer and use it in GitHub Desktop.
Color the rows of an HTML table with alternating classes, row and altRow. (jQuery)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Color the table rows by adding row and altRow classes to the table. | |
* Note: ignores any table rows with the class hidden. | |
* @param id The id of the table | |
*/ | |
function colorTableRows(id) { | |
var rows = $("table#" + id + " > tbody > tr").not("tr.hidden").removeClass("altRow row"); | |
rows.filter(":odd").addClass("altRow"); | |
rows.filter(":even").addClass("row"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment