当获取的是一组元素时,这样写为什么不行,我记得之前也有类似的写法啊??
check
check 2016-12-20 09:35:39
0
3
1086

$('li').css('color','red')

为什么不能这样直接设置


check
check

reply all(3)
数据分析师

When a set of elements is obtained, why doesn’t it work like this? I remember there was a similar way of writing it before? ? -PHP Chinese website Q&A-When a set of elements is obtained, why can't it be written like this? I remember that there was a similar way of writing it before? ? -PHP Chinese website Q&A

Please watch and learn.

/zt

Okay, but the settings are all a single color red.

迷茫
  $("li").each(function(index, element) {
            if (index % 2) {
                $(this).css('color','blue')
            }
        })

这里是2的倍数你可以用奇偶解决,可如果是3的倍数呢,如果,要按彩虹色呢,1,4,7红色,2,5,8蓝色,3,6,9黑色,或者别的,


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template