javascript添加或删除class类名

admin 阅读:58 2024-03-02
<div id="test">码农资源网(www.codesou.cn)</div>

<script>
let test = document.getElementById("test");
//原生js添加元素class类名
test.classList.add("active");
//原生js删除元素class类名
test.classList.remove("active");
</script>

引申阅读:JQuery添加或删除class类名

声明

1、部分文章来源于网络,仅作为参考。
2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!