Change the color of rows in a table using jquery
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("tr:odd").css("background-color", "yellow"); $("tr:even").css("background-color","red"); }); </script> </head> <title>Changing the background color of tr in a table using jquery</title> <body> <table border="1"> <tr> <td>My first row</td> </tr> <tr> <td>My second row</td> </tr> </table> </body> </html> |