Disable Click, Cut, Copy And Paste Using jQuery
Last Updated : Jul 1, 2023
In this tutorial we will show you how to disable right click, cut, copy and paste using jQuery means the user will not be able to right click cut copy and paste the text of a div after disabling using this method.
You may also like disable text selection using css.
CHECK OUT THIS TUTORIAL LIVE DEMO →
To Disable Click, Cut, Copy And Paste It Takes Only One Step:-
- Make a HTML file and define markup and scripting
Step 1. Make a HTML file and define markup and scripting
We make a HTML file and save it with a name disable.html
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function () { $('#modify_div').bind('cut copy paste', function (e) { e.preventDefault(); }); $("#modify_div").on("contextmenu",function(e) { return false; }); }); </script> </head> <body> <div id="wrapper"> <div id="modify_div"> <p> This is a sample content and This is a demo of Smooth Scrolling Div Using jQuery This is a sample content and This is a demo of Smooth Scrolling Div Using jQuery </p> </div> </div> </body> </html>
In this step we create a div and enter some sample text for click, cut, copy and paste and we
use $(document).ready to disable the click, cut, copy and paste after the page load.
In this we disable text operations only for 'modify_div' but you can disable text operations or any text operation for the complete webpage just insert 'body' in place of 'modify_div'.
You may also like enable disable keyboard keys using JavaScript.
Thats all, this is how to disable click, cut, copy and paste using jQuery. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
I hope this tutorial on disable click, cut, copy and paste using jQuery helps you and the steps and method mentioned above are easy to follow and implement.