Install
+ +You can get it on npm.
+ +npm install clipboard --save
+
+ Or bower, too.
+ +bower install clipboard --save
+
+ If you're not into package management, just download a ZIP file.
+ +Setup
+ +First, include the script located on the dist folder
<script src="dist/clipboard.min.js"></script>
+
+ Now, you need to instantiate it using a DOM selector. This selector corresponds to the trigger element, i.e. <button>.
<script> new Clipboard('.btn'); </script>
+
Usage
-First, you need to instantiate it using a DOM selector. This selector corresponds to the trigger element, i.e. <button>.
new Clipboard('.btn');
+ There are different options for you to use and they all take advantage of HTML5 data attributes.
Copy text from attribute
@@ -82,6 +102,32 @@ </button>As you may expect, the cut action only works on <input> or <textarea> elements.
Browser Support
+ +This library relies on both Selection and execCommand APIs. When combined, they're supported in the following browsers.
+ +-
+
-
+
+ Chrome 42+
+ -
+
+ Firefox 41+
+
+ -
+
+ IE 9+
+
+ -
+
+ Opera 29+
+
+ -
+
+ Safari ✘
+
+