jQuery Plugin To Handle Paste Events - Paste.js

File Size: 16.9 KB
Views Total: 1365
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
jQuery Plugin To Handle Paste Events - Paste.js

The jQuery Paste.js plugin provides 3 events to handle copy & paste events in a specific field that supports both text and image pasting.

How to use it:

1. Insert the JavaScript file jQuery Paste.js after jQuery JavaScript library.

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
<script src="paste.js"></script>

2. Call the function pastableTextarea on the element where you want to keep track of the paster event.

<textarea >Paste Text Or Image Here And Checkout The Console Log (F12).</textarea>

3. Trigger an event when you paste some text into the textarea.

.on('pasteText', function(event, text) {

4. Trigger an event when you paste an image into the textarea.

.on('pasteImage', function(event, image) {
    $('img').attr('src', image.dataURL);

5. Trigger an event when fail to paste.

.on('pasteError', function(event, err) {

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