mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
61f9e368b02c6d1347daa0966bfd48b6980f24b4
clipboard.js
A modern approach to copy & cut to the clipboard. No Flash. No dependencies. Just 1kb.
Install
You can get it using bower:
bower install clipboard --save
Or download as ZIP.
Usage
First, you need to instantiate it using a selector. This selector corresponds to the trigger element (usually a <button>).
new Clipboard('.btn');
The easiest way to copy some content to the clipboard, is to include a value attribute in your trigger element.
<button class="btn" value="lorem ipsum">Copy</button>
Another way of doing it is to copy the content from an <input> or <textarea>. You can do that by adding a for attribute in your trigger element. The value you include in this for attribute needs to match another's element id attribute.
<input id="target" value="Lorem ipsum">
<button class="btn" for="target">Copy</button>
Browser Support
![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|
| 42+ ✔ | 41+ ✔ | 9+ ✔ | 29+ ✔ | ✘ |
License
MIT License © Zeno Rocha
Description
✂️ Modern copy to clipboard. No Flash. Just 3kb gzipped 📋
https://clipboardjs.com
Readme
MIT
3.5 MiB
Languages
JavaScript
99.1%
TypeScript
0.6%
Shell
0.3%




