button copy javascript code example
Example 1: javascript copy to clipboard
var copyTextarea = document.getElementById("someTextAreaToCopy");
copyTextarea.select();
document.execCommand("copy");
Example 2: how to make a button that paste text in a textbox html
<!DOCTYPE html>
<html>
<head>
<script>
function paste() {
var pasteText = document.querySelector("#text");
pasteText.focus();
document.execCommand("paste");
pasteText.value = pasteText.value + pasteText.value;
}
</script>
</head>
<body>
<input id="text">
<button onclick="paste()">Paste</button>
</body>