How To Copy Markup - Not Just Plain Text - To The Clipboard Using Legacy Free Javascript
The complete content of a
Mary had a little lamb, its fleece was white as snow. Everywhere that mar
Solution 1:
I used to solve this problem using a fake textarea element copying my custom text into the clipboard.
Something like this should help:
const copyText = document.querySelector("myElement").innerHTML;
copyToClipboard(copyText);
functioncopyToClipboard(message) {
let textArea = document.createElement("textarea");
textArea.value = message;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy");
document.body.removeChild(textArea);
}
Post a Comment for "How To Copy Markup - Not Just Plain Text - To The Clipboard Using Legacy Free Javascript"