Home>

clipboard.js implements the function of copying pure javascript (no flash) browser content to the system clipboard.Can be used in browser and node environments.Supports chrome 42+, firefox 41+, ie 9+, opera 29+

Official website:https://github.com/zenorocha/clipboard.js

Official use method:https://zenorocha.github.io/clipboard.js/#example-text

Sample code:

Official example one:

<script src="clipboard.min.js"></script>
<!-Trigger->
<button data-clipboard-action="copy" data-clipboard-target="#bar">
  cut to clipboard
</button>
<script>
var clipboard=new clipboard (". btn");
clipboard.on ("success", function (e) {
  console.info ("action:", e.action);
  console.info ("text:", e.text);
  console.info ("trigger:", e.trigger);
alert ("Copy successfully");
  e.clearselection ();
});
clipboard.on ("error", function (e) {
  console.error ("action:", e.action);
  console.error ("trigger:", e.trigger);
});
</script>

Official example two:

<script src="dist/clipboard.min.js"></script>
<button>
<script type="text/javascript">
var clipboard=new clipboard (". btn");
clipboard.on ("success", function (e) {
  console.info ("action:", e.action);
  console.info ("text:", e.text);
  console.info ("trigger:", e.trigger);
  e.clearselection ();
});
clipboard.on ("error", function (e) {
  console.error ("action:", e.action);
  console.error ("trigger:", e.trigger);
});
</script>
  • Previous JS implements a super streamlined link list scrolling effect code in a fixed area
  • Next AngularJS basic ng-init directive simple example