Answers for "copy in js"

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
3

javascript copy to clipboard

<head><script>
function copyToCliBoard() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  copyText.setSelectionRange(0, 99999); /* For mobile devices */
  document.execCommand("copy");
  alert("Copied the text: " + copyText.value);
}
</script></head>

<body>
<input type="text" value="Hello World" id="myInput">
<button onclick="copyToCliBoard()">Copy text</button>
</body>
Posted by: Guest on March-15-2021
1

js copy to clipboard

navigator.clipboard.writeText("Hello, World!");
Posted by: Guest on April-21-2021
2

js copy to clipboard

Also works on safari!
  
function copyToClipboard() {
    var copyText = document.getElementById("share-link");
    copyText.select();
    copyText.setSelectionRange(0, 99999);
    document.execCommand("copy");
}
Posted by: Guest on May-17-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
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