This is a more practical function. After setting the odd and even rows to different colors, the experience of reading table data will obviously become better. Otherwise, the data will appear very complicated and crowded (the experience will be especially obvious when there are many rows of table data). Only when you actually do this aspect yourself will you have a strong experience. Anyway, I just experienced it, so I’ll leave it here for reference~
The core JS script code is as follows (the id of the table element is adjusted according to your own situation. The jquery-1.7.min.js in the code can be downloaded from the jquery official website)
Copy the code code as follows:
<script src="jquery-1.7.min.js"></script>
<script>
$(document).ready(function(){
SetTableRowColor();
});
//Use CSS to control the color of odd and even rows
function SetTableRowColor()
{
$("#Table tr:odd").css("background-color", "#e6e6fa");
$("#Table tr:even").css("background-color", "#fff0fa");
}
</scirpt>