copyme
v1.0.5
Published
simple copy to clipboard code
Downloads
2
Readme
Copy Me
The Copy Me is a simple JS code which allows you to add a copy event to your code for easy copy in your website or webapp.
How It Works
Add the
<script src="copyMe.min.js"></script>
to your HTML fileCreate any element you want to copy from giving it an id.
- E.g
<div id='copyMe'>The text here will be copied</div>
- E.g
Create an eventListener on an element that alters the copy Event with a specific id
- E.g
<button id='copy'>Copy</button>
- E.g
Add This to your JS file
In your js file, add an eventListener listening your element (e.g the button) either (click, mouseover, contextmenu....) . Then call the copyToClipboard()
function taking the id of the item(#copyMe
) you want to copy as the parameter.
Sample Code
document.querySelector('#copy').addEventListener('click', function(){
copyToClipboard(document.querySelector('copyMe'))
});
OR
Use Source Code Here.
But you need to follow Add This to your JS file step