mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
dist | ||
src | ||
.editorconfig | ||
.gitignore | ||
index.html | ||
package.json | ||
README.md |
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