Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Created October 21, 2010 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Takazudo/638415 to your computer and use it in GitHub Desktop.
Save Takazudo/638415 to your computer and use it in GitHub Desktop.
$.fn.zebraTable
/**
* $.fn.zebraTable
* $(anyTableElement).zebraTable() will attach 'odd' or 'even' to each trs.
*/
$.fn.zebraTable = function(){
return this.each(function(){
var $el = $(this);
var $tbody = $('tbody', $el);
$el = $tbody.size() ? $tbody : $el;
$('tr:odd', $el).addClass('odd');
$('tr:even', $el).addClass('even');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment