切换“活动”状态使用 jQuery 类,再次单击按钮时样式保留,但在 Firefox 中删除了类
我有一个问题。 - 仅在 Firefox 中
当我使用 jQuery 在链接上切换类“活动”时。如果我再次单击该链接,活动样式将保留。它仍然可见,直到我单击页面上的其他位置,但仅在 Firefox 中,但该类已被删除。
代码:
$('#quick-add-click').click( function() {
$(this).find('a').toggleClass('active');
});
有人遇到类似的问题吗?有一个简单的修复方法吗?
I have a problem. - only in Firefox
When I use jQuery to toggle a class 'active' on a link. The active style remains if I click the link again. It remains visible until I click somewhere else on the page but only in Firefox yet the class has been removed.
CODE:
$('#quick-add-click').click( function() {
$(this).find('a').toggleClass('active');
});
Anyone having any similar issues? Is there a simple fix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否正在使用 Mootools,或者即使您没有使用 Mootools,Mootools 也会被加载(Joomla 系统会自动发生)。我在使用 Firefox/Mootools/VEMap(Bing 地图)时遇到问题,也许您也遇到类似的问题。
Are you using Mootools or is Mootools being loaded even if you're not using it (happens automatically with Joomla systems). I had a problem with Firefox/Mootools/VEMap (Bing Maps) maybe you're having a similar problem.
无法重现它。
但是,也许您可以测试它是否可以在没有切换的情况下工作?
Couldn't reproduce it.
However, perhaps you can test if it works without toggle?
最小的例子,在 OSX Firefox 上看不到这种行为,
你能用 Firebug 检查一下当活动类不再存在时该样式来自哪里吗?
Minimal example, cannot see that behaviour on OSX Firefox
Could you check with Firebug where that style comes from when active class is not present anymore?
好的,我修复它的方法(以一种黑客的方式)是将
onfocus="blur()"
添加到锚元素OK so the way I fixed it (in a hacky way) was to add
onfocus="blur()"
to the anchor element