JSFiddle - React, Tailwind, and code Playground

by ianjmonk

HTML

<input id="input" \ type="text" placeholder="Enter text..." autocomplete="off"/>
<button id="copy" onclick="copyText()">Copy</button>

JavaScript

function copyText() {
  var copyText = document.getElementById("input");
  copyText.select();
  copyText.setSelectionRange(0, 99999); 
  navigator.clipboard.writeText(copyText.value);
  alert("Link copied.");
}