How to disable right click option using the jQuery ?

In this article, we will see how to disable the right-click option using the jQuery bind() method.

1. Syntax:

Syntax:

$(selector).bind(event, data, function);

Parameters:

This method accepts three parameters as mentioned above and described below:

  • event: It is an event type which is passed to the selected elements.
  • data: It is the data which can be shown over the selected elements.
  • function: It is the function which is performed by the selected elements.

Return Value: It returns all the modification made on the selected element.

2. Example:

Run the program to get the result:

<!DOCTYPE html>
<html>
<head>
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
    </script>
    <!-- This script will prevent right click -->
    <script>
        $(document).ready(function () {
            $(document).bind("contextmenu", function (e) {
                return false;
            });
        });
    </script>
    <style>
        h1 {
            color: green;
        }
        p {
            color: crimson;
        }
    </style>
</head>
<body>
    <center>
        <h1>Soltuts.com</h1>
        <p> In this article, we will see how to disable the right-click option using the jQuery bind() method. </p>
    </center>
</body>
</html>