Answers for "how to create a button that copy's current url to clipboard in jquery"

26

javascript text to clipboard

function copyToClipboard(text) {
   const elem = document.createElement('textarea');
   elem.value = text;
   document.body.appendChild(elem);
   elem.select();
   document.execCommand('copy');
   document.body.removeChild(elem);
}
Posted by: Guest on March-20-2020
1

js select and copy on click

document.getElementById("copy-text").onclick = function() {
  this.select();
  document.execCommand('copy');
  alert(window.getSelection().toString());
}
Posted by: Guest on May-13-2020

Code answers related to "how to create a button that copy's current url to clipboard in jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language