How to copy text to clipboard in JavaScript

1 Answer

0 votes
function copy_text_to_clipboard() {
    var text = document.getElementById("inputtextid");
    text.select();
    document.execCommand("copy");
    document.write("Copy Successes...");
}
        <input type="text" value="" id="inputtextid">
        <button onclick="copy_text_to_clipboard()">Copy text to clipboard</button>

 



answered Sep 17, 2019 by avibootz
edited Sep 17, 2019 by avibootz
...