Click Button Copy to Clipboard using jQuery

In this post we  learn how to Click Button Copy to Clipboard using jQuery. In this small tutorial i will notify you how to copy text from one field to another field using javascript, many time we have need to copy text value one field to another field, such as current address and perminant address are same in this criteria copy to clipboard is useful to save our time.

Read Also :  How to Email Validation using jQuery

Click Button Copy to Clipboard using jQuery

<!DOCTYPE html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <title>Copy To Clipboard Using JQuery-web-tuts.com</title>
  <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
  <script>
   $(document).ready(function(){
   $("button").click(function(){
    alert("Success");
    $("textarea").select();
    document.execCommand('copy');
  });

});
</script>
</head>
<body>
 <textarea id="comment" rows="5" cols="50"></textarea>
 <p><button type="button">Get Value</button></p>
 <p><strong>Note:</strong> Type something in the textarea and click the button to see the output.</p>
</body>
</html>