jQuery Plugin To Copy/Paste/Select Text - jQlipboard

File Size: 472 KB
Views Total: 2900
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
jQuery Plugin To Copy/Paste/Select Text - jQlipboard

jQlipboard is a simple jQuery clipboard plugin for handling copy, cut, paste, and select (highlight) events on the web app.

How to use it:

1. Load the main script JQlipboard.js after jQuery.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/JQlipboard.js"></script>

2. Copy any content to the clipboard.

// "Copied!" is copied
$.copy( "Copied!" ) 

// "1234" is copied
$.copy( 1234 ) 

// "false" is copied
$.copy( false ) 

// '{"hello":"world"}' is copied
$.copy( {hello: "world"} ) 

// "2021-01-01T05:00:00.000Z" is copied
$.copy( new Date("1/1/2021") ) 

// "<div>Hello World</div>" is copied
$.copy( document.querySelector("div") ) 

// "12345678901234567890" is copied
$.copy( 12345678901234567890n ) 

// "Hello World" is copied
$.copy( {toString: function(){return "Hello World"} ) 

3. Or copy text within a container element.

<div id="demo">This text will be coppied</div>
$( '#demo' ).copy();

4. Cut selected text to clipboard.

// select
$( "input" ).select();

// cut

5. Cut text within an element to clipboard and remove the element

// cut
$( ".element" ).cut();

// cut & remove
$( ".element" ).copy().remove();

6. Remove selection ranges.


7. Paste clipboard contents to text fields.

$( "input" ).focus();

8. Paste clipboard contents to elements.

$( ".element" ).paste();

9. Determine when the page will request permession to use the clipboard:

  • when needed (default)
  • immediate
  permissionPrompt: "when needed"

10. Determine whether to detect when you modify the clipboard on your own and to adjust the functions accordingly. Default: false.

  copyListener: true


v0.3 (2021-06-17)

  • Added cut & paste


  • Revert "New way of detecting POJO"


  • Better use of jQuery


  • Improvement


  • Cleanup JS.


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