CopyPasteJS
This a small JS library to execute clipboard functions in a fast and easy way.
Demo
See the demo here: https://assisfery.github.io/CopyPasteJS/index.html
Repositorys
Github repository: https://github.com/assisfery/CopyPasteJS
CDN repository: https://www.jsdelivr.com/package/gh/assisfery/CopyPasteJS
NPM repository: https://www.npmjs.com/package/copypastejs
Get Start
Just import the src/CopyPasteJS.js file in your document.
This file is hosted in CDN JSDelivr.
Or you can get it using NPM repository.
npm i copypastejs
Copy Text - From Input Element
To copy data from a input element just add data-copy-origin="#element" attribute to the button.
Copy
Copy Text - From Nowhere
To copy text to clipboard data-copy-text="text" attribute to the button.
Copy
Copy Text - From Others Element
To copy text to clipboard from a html element just include data-copy-text="text" attribute to the button.
Copy
Paste Text
To paste data to a input element just add data-paste-target="#element" attribute to the button.
Paste
Cut Text
To cut data from a input element just add data-cut-origin="#element" attribute to the button.
Cut
Copy and Paste Text
To copy and paste data from a input element to another just add data-copy-origin="#element" and data-paste-target="#element" attributes to the button.
Copy and Paste
Copy Callback function
After data is been copied if you want to execute a function just add data-copy-callback="jscode()" attribute to the button.
Copy and Callback
Paste Callback function
After data is been pasted if you want to execute a function just add data-paste-callback="jscode()" attribute to the button.
Paste and Callback
JavaScript Utils
You can do all those actions in JavaScript code.
Copy Text in JavaScript
CopyPasteJS;
Copy Text in JavaScript and Callback Function
CopyPasteJS;
Copy Value From Element in JavaScript
CopyPasteJS; // OR USE CALLBACKCopyPasteJS;
Paste To Element in JavaScript
CopyPasteJS; // OR CALL A FUNCTIONCopyPasteJS;
Cut Value From Element in JavaScript
CopyPasteJS; // OR CALL A FUNCTIONCopyPasteJS;