Salin teks ke clipboard javascript
//As simple as this
navigator.clipboard.writeText("Hello World");
Silly Sable
//As simple as this
navigator.clipboard.writeText("Hello World");
<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>
var copyTextarea = document.getElementById("someTextAreaToCopy");
copyTextarea.select(); //select the text area
document.execCommand("copy"); //copy to clipboard
var dummyContent = "this is to be copied to clipboard";
var dummy = $('<input>').val(dummyContent).appendTo('body').select()
document.execCommand('copy')