html 操作dom classLIst 属性

1.classList 属性

可以给指定的dom 增加多个class,他是只读的,只可以使用 add() 和 remove() 方法修改。

        eg:  document.getElementById("myDIV").classList.add("mystyle", "anotherClass", "thirdClass");

具体见菜鸟教程:https://www.runoob.com/jsref/prop-element-classlist.html

原文地址:https://www.cnblogs.com/wangliko/p/12206888.html