Home > Article > Web Front-end > js table alternate row color_javascript skills
Just judge whether it is an odd number
and then set the background color of the lower row
if(i%2==1) row.style.background = "#CCCCff";
else row .style.background = "#CCCCCC";