Jquery method to set different colors for rows: Use to set even to odd-numbered rows, and odd to set different colors for even-numbered rows. The code is [$('#t1 > tbody tr:even').css('background ','white');].
Jquery method of setting different colors for rows:
Assume that the id of the table is: t1
even is an odd number of lines, odd is an even number of lines
$(document).ready(function(){ $('#t1 > tbody tr:even').css('background','white'); $('#t1 > tbody tr:odd').css('background','#f1f5f8'); });
The effect is as shown:
Related free learning recommendations: JavaScript(Video)
The above is the detailed content of How to set rows to different colors in jquery. For more information, please follow other related articles on the PHP Chinese website!