Opera/IE7+ 吗? JQuery 支持 addClass/removeClass 吗?
我有用于模拟按钮的列表标签的 CSS,如下所示:
在调用 addClass 之前(理想情况下,removeClass 应该返回到什么)
#content_navigation li {
background-color:#C7C7C7;
border:2px outset black;
text-align:center;
font-weight:400;
}
After addClass('clicked');称为
#content_navigation li.clicked {
background-color:#EFEFEF;
border:1px inset black;
font-weight:700;
}
“我的 JQuery 代码”(对于一个按钮):
$('#pass_settings_btn').click(function() {
$('#pass_settings_btn').addClass('clicked');
$('li:not(#pass_settings_btn').removeClass('clicked');
在 Firefox 中,这工作得很好。但在 Opera/IE7 中(除了 Firefox 5 之外,这是我唯一需要测试的),但按钮不会返回到其原始状态。调用removeClass 后,原始CSS 并未“通过”。我该如何解决这个问题(希望没有特定于浏览器的黑客?)
I have CSS for list tags that emulate buttons, as follows:
Before addClass is called (and ideally, what removeClass should return to)
#content_navigation li {
background-color:#C7C7C7;
border:2px outset black;
text-align:center;
font-weight:400;
}
After addClass('clicked'); is called
#content_navigation li.clicked {
background-color:#EFEFEF;
border:1px inset black;
font-weight:700;
}
My JQuery code (for one button):
$('#pass_settings_btn').click(function() {
$('#pass_settings_btn').addClass('clicked');
$('li:not(#pass_settings_btn').removeClass('clicked');
In Firefox, this works perfectly. but in Opera/IE7 (the only ones I have to test on, apart from Firefox 5), but buttons don't go back to their original states. The original CSS isn't "coming through" after removeClass is called. How can I fix this (hopefully without a browser specific hack?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将
$('li:not(#pass_settings_btn').removeClass('clicked');
更改为
$('li:not(#pass_settings_btn)').removeClass('clicked' );
Try changing
$('li:not(#pass_settings_btn').removeClass('clicked');
to
$('li:not(#pass_settings_btn)').removeClass('clicked');