Q:

Distinguish between left and right mouse click with jQuery

0

Distinguish between left and right mouse click with jQuery.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code:

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Distinguish between left and right mouse click with jQuery</title>
  </head>
  <body>
  <h1 class="element">jQuery Exercises</h1>
  </body>
  </html>

JavaScript Code:

$(document).on("contextmenu", ".element", function(e){
   console.log('Right Mouse Clicked!');
   return false;
});

$(document).on('click', '.element', function(){
 console.log('Left Mouse Clicked!');
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now