Copy Text & Input Value To The Clipboard Using Pure JavaScript – Copyer.JS

Category: Javascript , Text | December 27, 2018
Authorspacetalehq
Last UpdateDecember 27, 2018
LicenseMIT
Views397 views
Copy Text & Input Value To The Clipboard Using Pure JavaScript – Copyer.JS

Copyer.JS is a vanilla JavaScript library that has the ability to copy text within a container of an input field to the clipboard using the document.execCommand API.

How to use it:

Import the JavaScript file copyer.js into the document.

<script src="./src/copyer.js"></script>

Call the copyer() function and specify the selector which holds the text you want to copy.

<p id="demo">CSSSCRIPT.COM</p>
<input id="demo-2" type="text" placeholder="CSSSCRIPT.COM">
copyer("demo");
copyer("demo-2");

You Might Be Interested In:


Leave a Reply