Copy to clipboard using javascript from data attribute
clipboard.js allow you to directly copy the text to clipboard from data-clipboard-text. If you want to copy the text by clicking a span and copy some entered text to clipboard we can use the following example.
HTML Code
Script
Example Program:- (Editor)

Editor is Loading...
Advertisement
HTML Code
<div id="btn" data-clipboard-text="This will copy">
<span>Click here</span>
</div>
Script
var clipboard = new Clipboard('#btn');
Example Program:- (Editor)
Editor is Loading...
Advertisement
Post a Comment for "Copy to clipboard using javascript from data attribute"