jQuery Copy to clipboard plugin - copy any text to the user site’s clipboard. Operates on the basis of creating hidden text field and executing “copy” command.
You can see DEMO page.
Be sure you have jQuery included in your website.
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script type="text/javascript" src="https://milankyncl.github.io/jquery-copy-to-clipboard/jquery.copy-to-clipboard.js"></script>
Works on any kind of element.
There are three ways to use this plugin.
$(document).ready(function() {
$('.element').CopyToClipboard();
});
<button data-clipboard-text="Text to copy.">Copy me!</button>
<button data-clipboard-target=".element">Copy another element's value!</button>
jQuery CopyToClipboard is based on creating hidden text field, inserting text and executing “copy” command.