Directory
- Welcome
Copy to Clipboard
The Copy to Clipboard script is a tool that helps you copy text to the clipboard. It is a tool that will help you copy text to the clipboard.
Usage
First add a content
dataset attribute to the element with the data you want to copy to the clipboard.
<p data-content="Hello World">Copy Me</p>
Next add the js-copy-clipboard
class to the element. Now when the element is clicked the data will be copied to the clipboard.
<p class="js-copy-clipboard">Copy Me</p>
When using a script to append this data you can add ClipboardElement
to the element for intellisense.
const copyButton = document.querySelector<HTMLButtonElement & ClipboardElement>('button');
copyButton.dataset.content = 'Hello World';