How to disable right click on div using context menu jquery?
Today, i am going to tell you how to disable mouse right click on div. this example thought you can learn how to disable right click on page or image or any html tag.
jquery provide contextmenu event that way we can prevent right click on specific html element. In this example i used contextmenu event with on().
So, let's see example code and check demo.
Example:
<html lang="en">
<head>
<title>Jquery - disable right click on div using context menu </title>
<script src="http://demo.itsolutionstuff.com/plugin/jquery.js"></script>
</head>
<body>
<div class="container">
<div class="my-div" style="width:500px;height:500px;background:red"></div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$(".my-div").on("contextmenu",function(){
return false;
});
});
</script>
</body>
</html>
So, let's check.....

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.