「jQuery入門」偶数行行で色分けするサンプル
書式
$(“tr:odd").css(“background-color", 値);
使用例
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("tr:odd").css("background-color", "red"); }); </script> </head> <body> <h1>test message</h1> <table border="1"> <tr> <th>Company</th> <th>Country</th> </tr> <tr> <td>AA01</td> <td>111</td> </tr> <tr> <td>BB02</td> <td>222</td> </tr> <tr> <td>CCC03</td> <td>333</td> </tr> <tr> <td>DDD04</td> <td>444</td> </tr> <tr> <td>EEE05</td> <td>555</td> </tr> </table> </body> </html>