How to make striped table rows with Javascript

By Chris on November 23, 2011 in php

1. Enter this Javascript in the head of your page along with the latest jquery pack ( )

<script type=”text/javascript” src=”** your scripts folder ***/jquery-latest.pack.js”></script>
<script type=”text/javascript”>
$(“table.tablerow tr:even”).addClass(“oddrow”);

2. Then create a line of CSS in your stylesheet:

.oddrow td { background-color:#eee }

3. Then add the class ‘tablerow’ to your HTML table

And that’s it!


About the Author

ChrisView all posts by Chris >


Leave a reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.