Zebra stripes with jQuery and CSS
Creating zebra stripes with CSS and jQuery. CSS will be used for the classes (odd and even rows) and jQuery to add the classes.
HTML
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
CSS
.zebra_odd {
background-color: #ABD5E0;
}
.zebra_even {
background-color: #38A7CB;
}
jQuery
$(document).ready(function() {
$('ul li:odd').addClass('zebra_odd');
$('ul li:even').addClass('zebra_even');
});
That’s it. Quite easy isn’t it.
Related posts:
- Hover effect with jQuery and CSS
- Disabling right mouse click menu with jQuery
- Automatic input field focus on page load
- Checking username availability with ajax using jQuery
- Client side filtering data with jQuery
Slobodan Kustrimovic
This author has yet to fill his BIO.
Did you absolutely LOVE this article... share it!
Comments
Leave your own!