0

How to access Clipboard in JavaScript

function paste() {
  navigator.clipboard.readText().then(clipText =>
  document.getElementById("outbox").innerText = clipText);
}

document.querySelector("#paste").addEventListener("click", paste);
<textarea id="outbox"></textarea>
<br/>
<button id="paste">Paste</button>
RUN
add comment
Suggest a different solution or add another example