ITeye博客

jquery 鼠标右键事件、左键单击事件判定

shenlm203 · 2010-10-28 15:06 · WEB前端 · jQuery · Web前端 · jQuery · Markdown

$(function(){ $('a').mousedown(function(e){ alert(e.which) // 1 = 鼠标左键 left; 2 = 鼠标中键; 3 = 鼠标右键 return false;//阻止链接跳转 }) })

如

$('#downwps2010').mousedown(function(e){ if(3 == e.which){ alert('这 是右键单击事件');

      }else if(1 == e.which){
               alert('这 是左键单击事件');
    
          }
    })

评论(3)

  1. #3 楼 · sunfeizhi · 2016-11-25 15:09

    very good!

  2. #2 楼 · liuchang615270 · 2016-05-20 10:22

    :idea:

  3. #1 楼 · lovebin_bin · 2010-11-15 17:20

    Very Good

评论功能维护中,当前仅展示历史评论。