JSFiddle - React, Tailwind, and code Playground
by techiedelight
HTML
<body>
<textarea id="content" rows="5" cols="30">Write something here...</textarea>
<button id="copy" title="Copy Textarea Content">Copy</button>
</body>
JavaScript
document.getElementById("copy").onclick = function() {
var text = document.getElementById("content").value;
navigator.clipboard.writeText(text)
.then(() => {
console.log('Text copied to clipboard');
})
.catch(err => {
console.error('Error in copying text: ', err);
});
}