Copying Text to Clipboard Using JavaScript

How To Copy to Clipboard

Hello Friends today in this article we will learn How to Copy Textbox value on clipboad on button click using javascript ? , and we will also learn how to show textbox value on label on button click using javascript ? , and includes with

how to hide label after 5 second using javascript ?

<div class="form-group">
        <input type="text" id="myInput" class="txtbox" value="Copy this text on button click using javascript"  />
        <input type="button" class="btn" onclick="myFunction()" value="COPY TEXT" />
function myFunction() {
  var copyText = document.getElementById("myInput");;
  copyText.setSelectionRange(0, 99999)
  alert( "Copied to clipboard " );
  var lblName = document.getElementById("mylabel");
  lblName.innerHTML = copyText.value;
  //Hide Label After 5 Second
        var seconds = 5;
        setTimeout(function () {
            document.getElementById("mylabel").style.display = "none";
        }, seconds * 1000);


Leave a Reply

Notify of