jQuery: Table Striping

Let's get started with jQuery by "striping" a table. The plain table comes from a list of United States Senators.

<script type="text/javascript" src="../js/jquery.js"> </script>
<script type="text/javascript">
$(document).ready(function() 
    { 
        $("#senatetable tbody tr:even").addClass('evenRow');
        $("#senatetable tbody tr:odd").addClass('oddRow');
    } 
);
</script>

Plain table:
table

Striped table:
table

Copyright © David Heitmeyer