我正在尝试禁用鼠标滚轮点击链接,但我不知道为什么它不起作用。 这是我的代码:
html:
<a class="disable_mousewheel_event" href="https://code.jquery.com/">Click</a>
javascript:
$(function() {
$(".disable_mousewheel_event").on("mouseup", function(event) {
if (event.which == 2) {
event.preventDefault();
}
});
})
答案 0 :(得分:0)
$(document).on("click", function(e) {
if($(e.target).is("a[href]") && e.button === 1) {
e.preventDefault();
}
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="https://code.jquery.com/">Click</a>
&#13;