Created
July 6, 2011 21:17
-
-
Save nateluzod/1068343 to your computer and use it in GitHub Desktop.
Zebra stripe a table or a list.
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
$.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