Disable right click in html page using jQuery

Last updated : May 10, 2017

Posted by: 1

We can disable or prevent right-click on HTML page using jQuery.

bind() method jQuery

The bind() method attaches one or more event handlers for selected elements and specifies a function to run when the event occurs.

Here we have attached bind() method with current HTML document.

Code:

<!DOCTYPE html>

<html>

<head>

<title>Jquery</title>

<script type="text/javascript" src="../js/jquery-3.2.1.min.js"></script>

</head>

<body>

<h1>Disable right click in html page using jquery.</h1>

<script>

$(document).bind("contextmenu",function(e) {

return false;

});

</script>

</body>

</html>