<input type="text" value="Hello World" id="myInput">
<button onclick="myFunction()">Copy text</button>
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();
document.execCommand("copy");
alert("Copied the text: " + copyText.value);
}