<body>
<img src = "" alt = ""/>
<img src = "" alt = ""/>
<img src = "" alt = ""/>
<img src = "" alt = ""/>
</body>
<script src = " ../ ../ js /jquery-3.1.1.min.js "></script>
<script>
$("img").addClass(function(index){
return "img" + (index + 1);
}); //给每个img插入不同的class属性
$("img").removeClass(function(index){
if (index % 2){
return "img" + (index + 1); //隔行移除class
}
});
</script>
jQueru中addClass和removeClass的使用
最新推荐文章于 2021-06-02 15:25:24 发布