Next example works fine on desktops:
function copy() {
var copyText = document.getElementById("targetId");
copyText.select();
document.execCommand("copy");
}
But it doesn't work under ios Safari.
UPDATED: My input's code
<input type="text" value="Hello World" id="myInput">