Write a jQuery code to distinguish between left and right mouse click

Write a jQuery code to distinguish between left and right mouse click

Write a jQuery code to distinguish between left and right mouse click

Answer : 

FILE NAME : SP.html

<html>
<head>
    <script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
    <title>SP Creation</title>
</head>
<body>
    <div class="container">
        <div class="text" id="box">
                <h2>Text Box</h2>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Odio, quas?</p>
        </div>
    </div>
    <script>
        $(document).ready(function(){
            $('body').click(function(){
                swal('Left mouse click...!');
            });
            $('body').contextmenu(function(){
                swal('right mouse click...!');
            });
        });
    </script>
    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</body>
</html>
Write a jQuery code to distinguish between left and right mouse click Write a jQuery code to distinguish between left and right mouse click Reviewed by technical_saurabh on April 29, 2021 Rating: 5

No comments:

Powered by Blogger.