如何删除 .class1、.class2、... 或 classN?
我们有这个类名
.lightbox620
.lightbox400
..
.lightbox200
,我们应用于正文页面,它决定了它的宽度...
所以我需要删除这个类,
我如何 $('body').removeClass('ligbox{any}')< /代码> ???
we have this classnames
.lightbox620
.lightbox400
..
.lightbox200
That we apply to the body page and it determines its width...
so i need to remove this class,
how can i $('body').removeClass('ligbox{any}')
???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是您设置为
的唯一类,则删除所有类。
如果不是,请采用普通 DOM 方式,使用正则表达式将类名从字符串中去除。
这里 jQuery 的方式有点复杂:
If that's the only class that you set to
<body>
, then remove all the classesIf not, go the plain DOM way, use a regular expression to strip the class name out of the string.
The jQuery way is a bit more complicated here: