4
如果您點擊並且不移動鼠標,您將看到按鈕的顏色保持爲紅色! 我想要完成的是在您單擊並且不移動鼠標之後,它仍然移除/切換.hover
類。如何刪除/切換元素上的懸停類(單擊後翻譯),而無需再次移動鼠標?
$(function() {
var $Btn = $('.button');
$Btn.hover(function() {
$(this).toggleClass("hover");
});
$Btn.on("click", function() {
$(this).toggleClass('active')
$('.move').toggleClass('angle');
});
});
.move {
border: 1px solid #000000;
padding: 10px;
transition: transform .2s ease;
/*
have noticed issue is in "transition"
*/
}
.button.hover {
color: red;
}
.angle {
transform: translate(100px, 0);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="move">
<button class="button">on click still red?</button>
</div>
是[這](http://jsfiddle.net/d795jt5o/),你需要什麼? – Harry
謝謝! @哈里 [結果非常棒!](http://robylayouts.com/file/btn-bug.gif) –