Create a Zebra Stripes table effect using jquery
HTML Code :
<!DOCTYPE html> <html> <head> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <meta charset="utf-8"> <style type="text/css">.table_style { width: 500px; margin: 0px auto; } table{ width: 100%; border-collapse: collapse; } table tr td{ width: 50%; border: 1px solid #ff751a; padding: 5px; } table tr th{ border: 1px solid #79ff4d; padding: 5px; } .zebra{ background-color: #ff0066; } </style> <title>Create a Zebra Stripes table effect</title> </head> <body> <div class="table_style"> <table> <tr> <th>Student Name</th> <th>Marks in Science</th> </tr> <tr> <td>Janet</td> <td>85.00</td> </tr> <tr> <td>David</td> <td>92.00</td> </tr> <tr> <td>Arthur</td> <td>79.00</td> </tr> <tr> <td>Bill</td> <td>82.00</td> </tr> </table> </div> </body> </html>
JavaScript Code :
$(document).ready(function(){ $("tr:odd").addClass("zebra"); });
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
HTML Code :
JavaScript Code :
need an explanation for this answer? contact us directly to get an explanation for this answer