Home > Web Front-end > JS Tutorial > How to set rows to different colors in jquery

How to set rows to different colors in jquery

coldplay.xixi
Release: 2020-11-18 10:58:43
Original
2866 people have browsed it

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');].

How to set rows to different colors in jquery

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');
});
Copy after login

The effect is as shown:

How to set rows to different colors in jquery

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template