JSFiddle - React, Tailwind, and code Playground

HTML

<input id="copy-text" type="text" value="Select a part of this text!">

JavaScript

document.getElementById("copy-text").onclick = function() {
  this.select();
  document.execCommand('copy');
  alert('This is a test...');
}