Skip links

How to make striped table rows with Javascript

November 23, 2011

1. Enter this Javascript in the head of your page along with the latest jquery pack ( http://docs.jquery.com/Downloading_jQuery )

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

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!

 

chris-parker
This website uses cookies to improve your web experience.
chris-parker

Send me a message.

Happy to answer any question you may have.

chris@chrisparkerdesign.co.uk

07813 311253

    Your Name (required)

    Your Email (required)

    Subject

    Your Message

    CHRIS PARKER DESIGN

    chris@chrisparkerdesign.co.uk

    07813 311253