How to use jquery to achieve an interlaced color effect:
Interlaced color effect in the site has a large number of applications, especially in similar news lists such functions, for row and row between the distinction there is a great advantage, but also improve the user-friendliness of the site, although it is a small function, but the site's traffic from such a small function points accumulated from the drip. This effect can be implemented using CSS, but since the existing browser is not good enough for CSS3 support, using JS or jquery is a good choice, here's how to use jquery to achieve this effect. The code example is as follows:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><styletype= "Text/css">ul{List-style:None;}</style><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function() {Jquery.changecolor=function(ulid) {varLiset=$ (ulid). Find ("Li"); for(varI=0; I<Liset.length;i+=2) {Liset.eq (i). CSS ("Background-color","Green"); }} $.changecolor ("#mytest");})</Script><Body><ulID= "MyTest"> <Li>First line</Li> <Li>A second line</Li> <Li>Alternating-changing Li</Li> <Li>Alternating-changing Li</Li> <Li>Alternating-changing Li</Li></ul></Body></HTML>
The above code can set the background color of odd rows to green.
The original address is: http://www.51texiao.cn/jqueryjiaocheng/2015/0427/248.html
How to use jquery to achieve interlaced color effects