I am looking for a simple way to hide/disable the right click context menu for the whole html page but not in some editable html elements just like input[text] and textarea using jquery.
I know this jquery code, but the below code will disable context menu in all html elements even in editable objects...
$(document).ready(function(){
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
});
Disable right click menu in html page using jquery. JavaScript Code: $(document). bind("contextmenu",function(e){ return false; });
Projects In JavaScript & JQuery To disable cut, copy and paste of a content in jQuery, use the jQuery bind() function.
$('img'). bind("contextmenu",function(e){ return false; }); That code will disable right-click on every image on your page. If you want to be more selective, assign the specific images you want to disable right-click for their own unique class, and then use that class name as the selector in place of the 'img' tag.
you could check for tags that you need like this:
$(document).ready(function(){
$(document).on("contextmenu",function(e){
if(e.target.nodeName != "INPUT" && e.target.nodeName != "TEXTAREA")
e.preventDefault();
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With