[英]jquery toggle/deactivate hover class on clicked state
So I have this code where when I hover over table row I get a blue background row color and when I click on the table row I get a gray background row color. 所以我有这段代码,当我将鼠标悬停在表格行上时,会得到蓝色背景行颜色,而当单击表格行时,我会得到灰色背景行颜色。
It almost works as I desire with one exception. 除了一个例外,它几乎可以按我的意愿工作。
When I click on the row and that row has a clicked class, then :hover class should not override the background color. 当我单击该行并且该行具有单击的类时,:hover类不应覆盖背景色。
ie the hover color should still be gray when I hover a row that has been clicked. 即当我将鼠标悬停在已单击的行上时,悬停颜色仍应为灰色。
Here is my javascript code: 这是我的JavaScript代码:
$('.my-class').click(function(){
$(this).nextUntil('tr.my-class').slideToggle(100);
$(this).toggleClass("clicked");
});
Here is my css class: 这是我的CSS类:
.my-class.negative:hover {
background-color: blue;
}
.my-class.negative.clicked {
background-color: gray;
}
here is my jsfiddle: http://jsfiddle.net/DhdRG/9/ 这是我的jsfiddle: http : //jsfiddle.net/DhdRG/9/
Just add: 只需添加:
.my-class.negative.clicked, .my-class.negative.clicked:hover {
background-color: gray;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.