✂️ Modern copy to clipboard. No Flash. Just 3kb gzipped 📋 https://clipboardjs.com
Go to file
2015-09-18 16:34:09 -07:00
dist Adds new "value" attribute that creates a fake element and select its content to clipboard 2015-09-18 16:32:57 -07:00
src Adds new "value" attribute that creates a fake element and select its content to clipboard 2015-09-18 16:32:57 -07:00
.editorconfig Hello world 2015-09-17 23:15:24 -07:00
.gitignore Includes babel configuration 2015-09-17 23:16:08 -07:00
index.html Adds minify task 2015-09-18 15:55:18 -07:00
package.json Adds minify task 2015-09-18 15:55:18 -07:00
README.md Adds intro documentation 2015-09-18 16:34:09 -07:00

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

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
42+ ✔ 41+ ✔ 9+ ✔ 29+ ✔

License

MIT License © Zeno Rocha