Copy To Clipboard JQuery

WebSolutionStuff | Aug-19-2020 | Categories : PHP jQuery

In this small tutorial i will explain you how to copy text from one field to another field using javascript,many time we have requirement to copy text value one field to another field, like current address and perminant address are same in this criteria copy to clipboard is useful to save our time.

So here i will give you some piece of code how to copy to clipboard using JQuery.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Copy To Clipboard Using JQuery-websolutionstuff.cpm</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> 

 

Featured Post