清除element.classList [英] Clear element.classList
本文介绍了清除element.classList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
element.classList
的类型为 DOMTokenList
类型。 / p>
是否有清除此列表的方法?
解决方案
我我没有意识到与 classList
相关的功能的方法。它具有 .add()
和 .remove()
方法来添加或删除单个类,但是您可以清除从这样的元素中删除所有类的意义上列出:
element.className =;
element.classList
is of DOMTokenList
type.
Is there a method to clear this list?
解决方案
I'm not aware of a "method" in the sense of a "function" associated with classList
. It has .add()
and .remove()
methods to add or remove individual classes, but you can clear the list in the sense of removing all classes from the element like this:
element.className = "";
这篇关于清除element.classList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文