Skip to content

Instantly share code, notes, and snippets.

@nateluzod
Created July 6, 2011 21:17
Show Gist options
  • Save nateluzod/1068343 to your computer and use it in GitHub Desktop.
Save nateluzod/1068343 to your computer and use it in GitHub Desktop.
Zebra stripe a table or a list.
$.fn.zebrafy = function(){
if($(this).get(0) != null){
var $im_a = $(this).get(0).tagName.toLowerCase();
var $stripe_element;
if($im_a == "table") {
$stripe_element = "tr"
} else {
$stripe_element = "li"
};
$(this).addClass("zebrafied").find($stripe_element + ":visible:odd").addClass("odd");
$($stripe_element).hover(
function () {
$(this).addClass("hover");
},
function () {
$(this).removeClass("hover");
}
);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment