Answers for "vanilla js copy to clipboard"

11

js copy text to clipboard

function copy() {
  var copyText = document.querySelector("#input");
  copyText.select();
  document.execCommand("copy");
}

document.querySelector("#copy").addEventListener("click", copy);
Posted by: Guest on September-17-2019
0

copy to clipboard javascript dom

navigator.clipboard.writeText('Text');
Posted by: Guest on February-02-2021
2

javascript copy to clipboard

$(document).ready(function(){
	$("#ewefmwefmp").click(function(){
    //alert()
      var copyText = document.getElementById("myInput");
      copyText.select();
      copyText.setSelectionRange(0, 99999)
      document.execCommand("copy");
      alert("Copied the text: " + copyText.value);
    
    });
});
Posted by: Guest on September-09-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language