jQuery使用非常简单的语句实现表格隔行变色效果
// jQuery $(function(){ $("tr.stripe:even").css("background-color", "#D0D0D0"); $("tr.stripe:odd").css("background-color", "#E5E5E5"); } // HTML <table> <tr class="stripe"> <td>Col 1</td> <td>Col 2</td> <td>Col 3</td> </tr> <tr class="stripe"> <td>Col 1</td> <td>Col 2</td> <td>Col 3</td> </tr> <tr class="stripe"> <td>Col 1</td> <td>Col 2</td> <td>Col 3</td> </tr> </table>