A JavaScript library providing text copying to clipboard.
https://codepen.io/k4zuki02h4t4/pen/oNmJYmr
- Put
<script src="/assets/js/TextToClipboard.min.js"></script>
. - Done.
Coding is quite simple. The options are only simple, so you won't get lost.
<div>
<div>
<button type="button" class="copyBtn">Copy</button>
<span class="copied" style="display: none">Copied!</span>
</div>
<label>
<textarea class="textBody">Hello World!</textarea>
</label>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
new TextToClipboard();
});
</script>
<div>
<div>
<button type="button" class="copyBtn">Copy</button>
<span class="copied" style="display: none">Copied!</span>
</div>
<label>
<textarea class="textBody">Hello World!</textarea>
</label>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
new TextToClipboard({
copyButtonClass: 'copyBtn',
copiedClass : 'copied',
textBodyClass : 'textBody'
});
});
</script>
MIT License
Copyright (c) 2023 Kaleid Pixel