jquery指定div右鍵事件

<div class="nav_list_item">須要淡季右鍵的div</div>

 咱們要 給這個div註冊鼠標右鍵的時候須要先禁用該div的網頁右鍵菜單,這裏用了unbind 若是有不清楚的能夠去看我上一篇博客spa

 $(".nav_list_item").unbind("mousedown").bind("contextmenu", function (e) {
            e.preventDefault();
            return false;

        });
   $(".nav_list_item").unbind("mousedown").bind("mousedown", function (event) {
            if (event.which == 3) {
                  alert(「」我單擊了右鍵「」)
            
            }else if(event.which == 1){
           alert("我單擊了左鍵");
} 
          
        });
 
相關文章
相關標籤/搜索