问题:
Instead of individually calling $("#item").removeClass()
for every single class an element might have, is there a single function which can be called which removes all CSS classes from the given element? 而不是为元素可能拥有的每个单独单独调用$("#item").removeClass()
,是否有一个可以调用的函数从给定元素中删除所有CSS类?
Both jQuery and raw JavaScript will work. jQuery和原始JavaScript都可以工作。
解决方案:
参考一: https://stackoom.com/question/5yhZ/如何使用jQuery-JavaScript删除所有CSS类参考二: https://oldbug.net/q/5yhZ/How-to-remove-all-CSS-classes-using-jQuery-JavaScript
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4254661