Javascript Copy to Clipboard from TextArea

Welcome Folks I am back with another blog post. In this post I will be talking about how to make a copy to clipboard widget in Javascript. Let’s follow the steps given below to make this application.

See also  Node.js Express Bulk Email Validator Online Tool in Javascript Full Project For Beginners



Whole Source Code


<!DOCTYPE html>
    <title>Copy to Clipboard</title>
    <textarea id="text" rows="13" cols="60">
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem, quas eveniet eaque maxime, iste veritatis corrupti minima laborum beatae voluptatem nihil, a tempora? At libero consectetur, porro eligendi sunt ratione.
    <button onclick="copy()">Copy</button>
    <textarea id="target" cols="60" rows="13"></textarea>

    function copy()
      var text = document.querySelector("#text");
      var range = document.createRange();



Leave a Reply