原生js实现添加删除和查询元素的class

版权声明:内容多为自言自语,请自行判断有无价值。 https://blog.csdn.net/weixin_41702247/article/details/84350895
<p id='p' class='dec'>hello</p>
.active{
    color:red;
}
.bigger{
    font-size:30px;
}
.dec{
    text-decoration:underline;
}
let p=document.getElementById('p');
p.classList.add('active','bigger');
p.classList.remove('dec');

参考:https://blog.csdn.net/qq_30100043/article/details/68060222

猜你喜欢

转载自blog.csdn.net/weixin_41702247/article/details/84350895