All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

Disable Click, Cut, Copy And Paste Using jQuery

Last Updated : Jul 1, 2023

IN - jQuery HTML | Written & Updated By - Pragati

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.

Disable Click, Cut, Copy And Paste Using jQuery

To Disable Click, Cut, Copy And Paste It Takes Only One Step:-

  1. 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.

Author Image About Pragati

Experienced coding content writer who enjoys breaking down complex concepts in programming languages like Java, Python, C, and C++. Over three years of experience producing interesting and relevant content for a variety of entities. Committed to providing concise and easy-to-understand articles that assist readers in easily understanding technology and industry trends in the world of coding and software development.

Follow Pragati On Linkedin 🡪