FireFox mousedown干掉:active实例页面
展示
代码
-
HTML:
正常情况: <a href="javascript:" class="active-btn">按下</a> 包含JS: <a href="javascript:" id="button" class="active-btn">按下</a>
-
CSS:
.active-btn { display: inline-block; background-color: #cd0000; } .active-btn:active { background-color: #ae0000; }
-
JavaScript:
var button = document.getElementById("button"); if (button.addEventListener) { button.addEventListener("mousedown", function(event) { // 此处省略N行 event.preventDefault(); }); }