本文实例讲述了js实现class样式的修改、添加及删除的方法。分享给大家供大家参考。具体分析如下:
比较常见的js前端功能,通过修改标签的className实现相应的功能。
具体代码如下:
<script>
$(\'.goods_sale_property\').click(function(){//单独a标签点击添加class
if($(this).hasClass(\'goods_sale_property_checked\')){
$(this).removeClass(\'goods_sale_property_checked\');
}else{
$(this).addClass(\'goods_sale_property_checked\');
}
});
function selectAll(){//全选添class
$(\'.goods_sale_property\').each(function(i){
$(this).addClass(\'goods_sale_property_checked\');
});
}
function selectNotAll(){//全选删除class
$(\'.goods_sale_property\').each(function(i){
$(this).removeClass(\'goods_sale_property_checked\');
});
}
</script>
本文地址:https://www.stayed.cn/item/8738
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我