My code to copy the text inside the field:
window.copyToClipboard = function(elementId) {
var aux = document.getElementById(elementId);
aux.select();
document.execCommand("copy");
alert('copy');
}
<input type="text" id="fldID" value="test">
<input type="submit" onclick="copyToClipboard('fldID');">
My problem : How to disable selection after copying?