Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

copy to clipboard using javascript

function handleCopyTextFromParagraph() {
  const cb = navigator.clipboard;
  const paragraph = document.querySelector('p');
  cb.writeText(paragraph.innerText).then(() => alert('Text copied'));
}
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #copy #clipboard #javascript
ADD COMMENT
Topic
Name
2+5 =