JavaScript Copy to Clipboard Button

<input type="text" readonly value="Text Coppied Hello World" id="myInput">
<button onclick="myFunction()">Copy text</button>
<script>
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();

document.execCommand("copy");
copyText.blur();

alert("Copied the text: " + copyText.value);
}
</script>
0

Leave a Reply