Copy the code.

<textarea id="copy1">Text to copy here.</textarea>
<button type="button" onclick="copyEvent('copy1')">Copy Above Text</button>
<script>
function copyEvent(id) {
	var str = document.getElementById(id);
	window.getSelection().selectAllChildren(str);
	document.execCommand("Copy"); //Copies selected text
	window.getSelection().removeAllRanges();
	console.log('Copied text from #' + id + '.');
}
</script>
		

Don't believe the text is copied? Paste here.