<html> <head> <style> .odd { height: 5px; background: #960; } .even { height: 5px; background: #09C; } </style> <script src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('div:odd').addClass('odd'); $('div:even').addClass('even'); }) </script> </head> <body> <div></div> <div></div> <div></div> <div></div> <div></div> </body> <html>