如何使用jQuery / JavaScript删除所有CSS类?

巧了我就是萌 提交于 2020-04-27 06:46:22

问题:

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!