JSFiddle - React, Tailwind, and code Playground
HTML
<script>
document.addEventListener("copy", function(e) {
// The last one ends up on the clipboard.
e.clipboardData.setData("text/plain", "plain text");
e.preventDefault();
});
function f() {
console.log(document.execCommand("copy"));
}
</script>
<button onclick="f()">Button</button>
<div class="editable"></div>