How to achieve interlaced color change in jquery

青灯夜游
Release: 2022-04-22 17:25:07
Original
1882 people have browsed it

Implementation method: 1. Use "$("Element:nth-of-type(keyword)")" to select elements in even rows and odd rows respectively, set "even" to select even elements, and "odd" "Optional odd-numbered elements; 2. Use "css("color attribute", "color value")" to add different color styles to even-numbered rows and odd-numbered rows elements respectively.

How to achieve interlaced color change in jquery

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

jquery realizes interlaced color change

Implementation method:

  • Use :nth-of-type()The selector selects even rows and odd rows

  • Use css() to add styles to even rows and odd rows respectively, with different settings Color Color

Implementation Example:

      
商品 价格
T恤 ¥100
牛仔褂 ¥250
牛仔库 ¥150

Copy after login

How to achieve interlaced color change in jquery

Description:

:nth- of-type(n) selector selects all elements that are the nth child element of a specific type from its parent element.

When used with the keywords even and odd, you can select even and odd rows

  • even selects each even sub-element.

  • odd Select every odd child element.

【Recommended learning:jQuery video tutorial,web front-end video

The above is the detailed content of How to achieve interlaced color change 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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!