Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

extract text from html to clipboard javascript

function handleCopyTextFromParagraph() {
  const body = document.querySelector('body');
  const paragraph = document.querySelector('p');
  const area = document.createElement('textarea');
  body.appendChild(area);

  area.value = paragraph.innerText;
  area.select();
  document.execCommand('copy');

  body.removeChild(area);
}
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #extract #text #html #clipboard #javascript
ADD COMMENT
Topic
Name
9+7 =