How TO Add copy to clipboard Button On Page

This article will show you how to copy text to the clipboard without using any third-party library.

        function copyToClipboar() {
            /* Get the textarea */
            var copyText = document.getElementById("clipText");

            /* Select the text field */
            copyText.setSelectionRange(0, 99999); /*For mobile devices*/

            /* Copy the text inside the text field */

            /* debug */
            // alert("Copied the text: " + copyText.value);

    <textarea id='clipText'>
        Enter Text And Click Button To Copy Text To ClipBoard</textarea>
    <br />
    <input type="button" onclick="copyToClipboar()" value="Copy" />


Post a Comment

Please do not post any spam link in the comment box😊

Previous Post Next Post

Blog ads