Answers for "copy text by click javascript"

0

javascript click to copy

function copyToClipboard(value) {
  navigator.clipboard.writeText(value)
}
Posted by: Guest on August-12-2021
0

Javascript copy text onclick

const span = document.querySelector("span");

span.onclick = function() {
  document.execCommand("copy");
}

span.addEventListener("copy", function(event) {
  event.preventDefault();
  if (event.clipboardData) {
    event.clipboardData.setData("text/plain", span.textContent);
    console.log(event.clipboardData.getData("text"))
  }
});
Posted by: Guest on June-28-2021

Code answers related to "copy text by click javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language