删除悬停样式?
我有一个表和这样的样式:
.highlightrows tbody tr:hover {
background-color: #aaaaff;
}
然后我在该行上有一个单击处理程序,以从表中删除该行并将其添加到另一个表中。当我单击鼠标时,我当然将鼠标悬停在该行上,因此应用了样式。 我的问题是,当我将其附加到另一个表时,悬停样式不会被删除。如何删除 jQuery 中的样式?
编辑: 我做了一个 jsFiddle 来描述我的问题。 小提琴
I have a table and a style like this:
.highlightrows tbody tr:hover {
background-color: #aaaaff;
}
Then I have a click handler on this row to remove the row from the table and add it to another table. When I click on the mouse I'm of course hover over the row and therefor is the style applied.
My problem is that when I append it to the other table the hover-style is not removed. How can I remove the style in jQuery?
Edit:
I've made a jsFiddle to discribe my problem. fiddle
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你有两张桌子...为什么不这样做呢?
you have two tables... why not do it this way??
哈,这似乎是浏览器的一个错误,因为您不再将鼠标悬停在该元素上。
无论如何,您可以尝试
或以其他方式将其设置为其默认颜色,在移动它之后。
:hover 不是一种样式,据我所知,您无法从元素中删除它 - 只有浏览器可以做到这一点。您唯一能做的就是在实际元素上强制使用默认样式
Ha, that seems to be a bug with the browser, as you are no longer hovered over the element.
Anyway, you could try
Or otherwise set it to its default color, after you move it.
:hover is not a style, and AFAIK you can't remove it from an element - only the browser can do that. The only thing you can do is force the default style on the actual element
我刚刚遇到这个问题。
我的 CSS 中有一个 :hover 样式,在运行 java 脚本时我不希望 :hover 生效。我找不到删除该类的方法,因此我决定通过将带有新属性的新类附加到头部来覆盖该类。
CSS
JavaScript
希望有帮助
I was just running into this issue.
I had a :hover style in my CSS and while running java script I didn't want :hover to be in effect. I couldn't find a way to remove the class so I decided to overwrite the class by appending a new class with my new attributes to the head.
CSS
JavaScript
hope that helps