https://github.com/assisfery/copypastejs
This a small JS library to execute clipboard functions in a fast and easy way.
https://github.com/assisfery/copypastejs
clipboard copy-paste copy-to-clipboard javascript javascript-library
Last synced: about 1 month ago
JSON representation
This a small JS library to execute clipboard functions in a fast and easy way.
- Host: GitHub
- URL: https://github.com/assisfery/copypastejs
- Owner: assisfery
- Created: 2019-11-04T11:40:19.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-10T18:25:17.000Z (about 5 years ago)
- Last Synced: 2025-03-22T12:18:49.978Z (2 months ago)
- Topics: clipboard, copy-paste, copy-to-clipboard, javascript, javascript-library
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 19
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## CopyPasteJS
This a small JS library to execute clipboard functions in a fast and easy way.
[](https://www.jsdelivr.com/package/gh/assisfery/CopyPasteJS)
[](https://www.npmjs.com/package/copypastejs)### Demo
See the demo here: [https://assisfery.github.io/CopyPasteJS/index.html](https://assisfery.github.io/CopyPasteJS/index.html)### Repositorys
Github repository: https://github.com/assisfery/CopyPasteJSCDN 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.
```html```
This file is hosted in CDN JSDelivr.
```html```
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.
```html
Copy
```### Copy Text - From Nowhere
To copy text to clipboard **data-copy-text="text"** attribute to the button.
```html
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.
```html
Copy
```### Paste Text
To paste data to a input element just add **data-paste-target="#element"** attribute to the button.
```html
Paste
```### Cut Text
To cut data from a input element just add **data-cut-origin="#element"** attribute to the button.
```html
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.
```html
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.
```html
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.
```html
Paste and Callback
```### JavaScript Utils
You can do all those actions in JavaScript code.#### Copy Text in JavaScript
```js
CopyPasteJS.copyText("Text copied in JS");
```#### Copy Text in JavaScript and Callback Function
```js
CopyPasteJS.copyText("Text copied in JS and Callback triggered", function(){
alert("Yes its done");
});
```#### Copy Value From Element in JavaScript
```js
CopyPasteJS.copyFrom("#txtCopy4");// OR USE CALLBACK
CopyPasteJS.copyFrom("#txtCopy4", function(){
alert(123);
});
```#### Paste To Element in JavaScript
```js
CopyPasteJS.pasteTo("#txtPaste4");// OR CALL A FUNCTION
CopyPasteJS.pasteTo("#txtPaste4", function(){
alert("I fell amazing");
});
```##### Cut Value From Element in JavaScript
```js
CopyPasteJS.cutFrom("#txtCut2");// OR CALL A FUNCTION
CopyPasteJS.cutFrom("#txtCut2", function(){
alert("I fell amazing");
});
```