首页javascriptmousejQuery Event - 如何检测鼠标中键单击事件

jQuery Event - 如何检测鼠标中键单击事件

我们想知道如何检测鼠标中键单击事件。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(function(){
    $(document).on("mousedown", "a.external", function(e) {
       console.log(e.which);
       if( e.which <= 2 ) {
          e.preventDefault();
          console.log ("Button clicked: " + e.which);
       }else{
          console.log ("Button clicked else: " + e.which);
       }
       
    });
});
</script>
</head>
<body>
  <a class="external">Test</a>
</body>
</html>