on button click copy the html code code example
Example 1: 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>
Example 2: jquery copy to clipboard
document.execCommand("copy");