DEV Community

Technical Vandar
Technical Vandar

Posted on

Copy to clipboard using javascript.

Here is the code for copy to clipboard using pure javascript you can use this code on your project for copy something.

Code

function Copy(){
        var copyText=document.getElementById("textbox");
        copyText.select();
        copyText.setSelectionRange(0, 999);
        document.execCommand("copy");
        alert("Copied");
    }
Enter fullscreen mode Exit fullscreen mode

Using this code you can copy the content of textbox in webpage.

Top comments (0)