Finds even table rows, matching the first, third and so on (index 0, 2, 4 etc.) using jquery
HTML Code :
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-git.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Finds even table rows, matching the first, third and so on.</title> <style type="text/css"> button { display: block; margin: 20px 0 0 0; } </style> </head> <body> <table border="1"> <tr><td>R1C1 Index-0</td><td>R1C2 Index-0</td></tr> <tr><td>R2C1 Index-0</td><td>R2C2 Index-1</td></tr> <tr><td>R3C1 Index-0</td><td>R3C2 Index-2</td></tr> <tr><td>R4C1 Index-0</td><td>R4C2 Index-3</td></tr> <tr><td>R5C1 Index-0</td><td>R5C2 Index-4</td></tr> </table> <button id="button1">Click to see the effect</button> </body> </html>
JavaScript Code :
$('#button1').click(function(){ $( "tr:even" ).css( "background-color", "orange" ); });
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 :