Home > Web Front-end > JS Tutorial > jQuery realizes interlaced background color change_jquery

jQuery realizes interlaced background color change_jquery

WBOY
Release: 2016-05-16 16:30:26
Original
1454 people have browsed it

There are many ways to achieve interlaced color change. In the past, I wrote the judgment code directly in the program. Today we will use jQuery to implement it. Here is the code~

jQuery code:

Copy code The code is as follows:

        $(function(){
            var item = $("tr");
for(var i=0;i If(i%2==0){
item[i].style.backgroundColor="#888";
                                                                                                                     }
//$("#tb tbody tr:even").css("backgroundColor","#888");

        });

HTML code:

Copy code The code is as follows:

                                                                                                                                                                                                                                                                                          
                                                                                                                                                           
                                     
                                       
                                  
                                                                                         
First LineFirst Line
The third lineThe third line
Line 4Line 4
Line 5Line 5
Line 6Line 6




Isn’t it fun? Friends, you can actually use jQuery to achieve many fun things. Let’s use it freely
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