jq模仿右鍵觸發選單

遠方*發表於2020-10-21
//contextmenu()表示右鍵選單觸發的時候

$(document).contextmenu(function(event){
 
        x=event.clientX;
 
        y=event.clientY;
 
        btn=event.button;
 
        if(btn==2){
 
                $('ul').show().css({'left':x+'px','top':y+'px'});
 
                return false;
 
        }
 
});
//clientX與offset

        function start(event) {
 
            deltaX=event.clientX-obj.offset().left;
 
            deltaY=event.clientY-obj.offset().top;
 
        }

相關文章