Answers for "clipboard 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

copy text to clipboard jquery

function copyToClipboard(element) {
 var $temp = $("<input>");
 $("body").append($temp);
 $temp.val($(element).html()).select();
 document.execCommand("copy");
 $temp.remove();
}
Posted by: Guest on November-08-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
11

copy to clipboard javascript

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
1

js copy to clipboard

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

how to copy text in the clipboard in js

<html>
  <input type="text" value="Hello world"(Can be of your choice) id="myInput"(id is the name of the text, you can change it later)
<button onclick="Hello()">Copy Text</button>

<script>
  function Hello() {
  var copyText = document.getElementById('myInput')
  copyText.select();
  document.execCommand('copy')
  console.log('Copied Text')
}
</script>
Posted by: Guest on October-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language