点击的时候,按钮会变橙色,松开变回白色。处于点击状态时,离开会变回白色,进去又为橙色。
但松开后,离开和进入的效果被保存到css了。
怎么让完成一次点击事件后,无效掉进入与退出的效果。
$(".bottom .button").on({
mousedown:function(){
$(this).css("background-color","#FD9917").css("color","white")
.on({
mouseenter:function(){
$(this).css("background-color","#FD9917").css("color","white")},
mouseleave:function(){
$(this).css("background-color","white").css("color","black")}
})
},
mouseup:function(){
$(this).css("background-color","white").css("color","black")
}
})
First of all, the poster needs to understand,
事件的绑定没有嵌套,不嵌套的
.Once an event is bound, it will always be valid and fixed.
Unless unbound.
The following method also works.
First of all, I suggest you write css to achieve this effect
If you insist on writing js:
Write it into css, and then addClass class name in the event
After the event is executed, there will be a callback event, and in the callback event removeClass
You can use css pseudo-classes to achieve
a:link { } / Unvisited links /
a:visited { } / Visited links /
a:hover { } / When the mouse is hovering over the link /
a:active { } / The selected link /
Isn’t it very easy to achieve the effect you want using CSS pseudo-classes? As for what you said, after releasing, the effects of leaving and entering are saved to css. What is the requirement for this?