Answers for "copy clipboard in js"

1

copy button value to clipboard function javascript

//U need to have a button with the id the same as its name because it is going to be sent to the clipborad.
/*Like this: */
<button onClick="SelfCopy(this.id)"  id="1">1</button>
<button onClick="SelfCopy(this.id)"  id="2">2</button>
<button onClick="SelfCopy(this.id)"  id="3">3</button>

function SelfCopy(copyText)
  {
      navigator.clipboard.writeText(copyText);
      alert("You just copied this: (" + copyText + ").");
  }
Posted by: Guest on April-24-2021
2

javascript how-do-i-copy-to-the-clipboard-in-javascript

function copyToClipboard(text) {
  var input = document.body.appendChild(document.createElement("input"));
  input.value = text;
  input.focus();
  input.select();
  document.execCommand('copy');
  input.parentNode.removeChild(input);
}
Posted by: Guest on May-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language