“cara menyalin teks di clipboard di js” Kode Jawaban

cara menyalin teks di clipboard di 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>
Upset Unicorn

Salin JavaScript ke 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);
    
    });
});
A D Bhowmick

Salin teks ke clipboard javascript

<script>
function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
}
</script>

<p id="text">Hello</p>
<button onclick="copyToClipboard('#text')"></button>
Xanthous Xenomorph

Jawaban yang mirip dengan “cara menyalin teks di clipboard di js”

Pertanyaan yang mirip dengan “cara menyalin teks di clipboard di js”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya