Copy Text Selection To Clipboard - jQuery Copy.js

Copy Text Selection To Clipboard - jQuery Copy.js
File Size: 7.77 KB
Views Total: 2307
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Copy.js is an extremely lightweight jQuery copy to clipboard plugin that allows copying any text you specify to the clipboard using document.execCommand('copy') API.

How it works:

  1. Create a temporary textarea in the document.
  2. Insert the selected text into the textarea.
  3. Copy the textarea element to the clipboard.
  4. Remove the textarea.

More copy to clip plugins:

How to use it:

1. Place both jQuery library and the jQuery Copy.js plugin at the end of the html document so the page loads fast.

<script src="jquery.min.js"></script>
<script src="jquery.copy.js"></script>

2. Copy the text within a specific container to the clipboard.

$.copy($("h3").text());
$.copy($("p"));
...

Change log:

2017-07-05

  • check nonexist jqury object

This awesome jQuery plugin is developed by by-syk. For more Advanced Usages, please check the demo page or visit the official website.