jquery-copy-to-clipboard

jQuery - Copy to clipboard Plugin

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.

Usage

1. Including jQuery

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>

2. Include CopyToClipboard jQuery extension

<script type="text/javascript" src="https://milankyncl.github.io/jquery-copy-to-clipboard/jquery.copy-to-clipboard.js"></script>

3. Run CopyToClipboard function

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>

4. More information

jQuery CopyToClipboard is based on creating hidden text field, inserting text and executing “copy” command.