jQuery
[jQuery] mousedown - event.which (마우스 좌,우,휠 클릭 판단)
힘없는염소
2016. 1. 19. 16:46
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <!DOCTYPE html> <html lang="ko"> <head> <meta charset="utf-8"> <style> html, body { height: 100%; background: skyblue; } </style> <script src="js/jquery.js"></script> </head> <body> <script> // click 이벤트는 좌클릭만 받을 수 있으므로 mousedown이벤트를 사용 $("body").mousedown(function(e) { $(this)[0].oncontextmenu = function() { // 우클릭시 띄워치는 contextmenu 막기 return false; } console.log(e.which); // 1:좌클릭, 2:휠클릭, 3:우클릭 }); </script> </body> </html> |
반응형