/* return content of input field to variable text */
var text = document.getElementById("text");
/* return button to variable btn */
var btn = document.getElementById("btn");
/* call function on button click */
btn.onclick = function() {
text.select();
document.execCommand("copy");
}