Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> <style> #divId { padding: 100px; border: 3px solid red; font-size: 30px; text-align: center; } </style> </head> <body> <div id="divId"> [Click here] </div> <script> $('#divId').mousedown(function(event) { switch(event.which) { case 1: $('#divId').html('Left Mouse button pressed.'); break; case 2: $('#divId').html('Middle Mouse button pressed.'); break; case 3: $('#divId').html('Right Mouse button pressed.'); break; default: $('#divId').html('You have a strange Mouse!'); } }); </script> </body> </html>