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
coldplay.xixiOriginal
2020-11-18 10:58:432864browse

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

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!

Statement:
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

Related articles

See more