kopiert
v1.0.7
Published
Kopiert (copies) text to the clipboard in the browser
Downloads
3
Readme
📋 Kopiert
Kopiert (copies) text to the clipboard in the browser
👋 Introduction
It's quite simple, include kopiert in your site and start copying text to the clipboard.
🚀 Get started
Script tag
Add this to your HTML page:
<script src="https://cdn.jsdelivr.net/npm/kopiert/dist/kopiert.min.js"></script>
<script>
kopiert.toClipboard('This text will be copied to your clipboard') // For example on a button press
</script>
NPM
Install kopiert using NPM:
npm install kopiert
Then add the following JavaScript code:
import kopiert from 'kopiert'
kopiert.toClipboard('This text will be copied to your clipboard')
Both methods will copy the specified text to the users clipboard.
📖 Examples
On button click
<p id="text">This text will be copied to your clipboard.</p>
<button id="btn">Copy text</button>
<script src="https://cdn.jsdelivr.net/npm/kopiert/dist/kopiert.min.js" ></script>
<script>
document.getElementById('btn').addEventListener('click', function() {
const text = document.getElementById('text').textContent
kopiert.toClipboard(text)
})
</script>
💻 Development
- run
yarn lint
ornpm run lint
to run eslint. - run
yarn build
ornpm run build
to produce a minifed version in thedist
folder.
❔ About
This project was developed by me (@betahuhn) in my free time. If you want to support me:
📄 License
Copyright 2021 Maximilian Schiller
This project is licensed under the MIT License - see the LICENSE file for details.