我有<button>
通过按空格键来激活,这是我不想要的,所以我使用e.preventDefault();
也禁用了
&#39;单击&#39;事件,但按钮&#39;保持视觉和压力#39;有什么问题吗?
使用e.stopPropagation();
完全没有效果。
$("#but").click(function(event){
event.preventDefault();
});
$("#foo").click(function(){
alert("Button stay 'pressed' until close the alert!");
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="foo">
<button id="but">button</button>
</div>
&#13;
答案 0 :(得分:0)
如果您想设置一个已被点击的按钮&#39;看起来它没有,你可以在你的CSS中使用:active
。
e.g。
button:active {
// reset the 'pressed' styles here.
}