The HTML:
Here's the JS code:HTML Code:<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" type="text/css" href="refresh.css"/> <script type="text/javascript" src="refresh.js"></script> </head> <body> <table> <caption>Itinerary</caption> <thead> <tr> <th>When</th> <th>Where</th> </tr> </thead> <tbody> <tr> <td>June 9th</td> <td>Portland, <abbr title="Oregon">OR</abbr></td> </tr> <tr> <td>June 10th</td> <td>Seattle, <abbr title="Washington">WA</abbr></td> </tr> <tr> <td>June 12th</td> <td>Sacramento, <abbr title="California">CA</abbr></td> </tr> </tbody> </table> </body> </html>
Code:function stripeTables() { if (!document.getElementsByTagName) return false; var tables = document.getElementsByTagName("table"); var odd, rows; for (var i=0; i<tables.length; i++) { odd = false; rows = tables[i].getElementsByTagName("tr"); for (var j=0; j<rows.length; j++) { if (odd == true) { rows[j].style.backgroundColor = "#ffc"; odd = false; } else { odd = true; } } } }
Thanks alot everyone


Reply With Quote

Bookmarks