Copy Text To Clipboard jQuery copiq - Download Copy Text With Structure & Formatting To Clipboard - jQuery copiq

Download Copy Text With Structure & Formatting To Clipboard – jQuery copiq

Posted on

This time I will share jQuery Plugin and tutorial about Copy Text With Structure & Formatting To Clipboard – jQuery copiq, hope it will help you in programming stack.

Copy Text To Clipboard jQuery copiq - Download Copy Text With Structure & Formatting To Clipboard - jQuery copiq

File Size: 5.34 KB
Views Total: 3921
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

copiq is a cross-browser copy to clipboard plugin for jQuery library which allows you to copy and paste any text while preserving the text structure and basic formatting (e.g. bold and italic).

How to use it:

1. Download and insert the jQuery copiq plugin’s script after jQuery library.

1 <script src="//code.jquery.com/jquery.min.js"></script>
2 <script src="jquery.copiq.js"></script>

2. Create a SVG based copy button as this:

1 <svg xmlns="http://www.w3.org/2000/svg" style="display: none">
2     <symbol id="icon-copy" viewBox="0 0 32 32">
3         <path d="M20 8v-8h-14l-6 6v18h12v8h20v-24h-12zM6 2.828v3.172h-3.172l3.172-3.172zM2 22v-14h6v-6h10v6l-6 6v8h-10zM18 10.828v3.172h-3.172l3.172-3.172zM30 30h-16v-14h6v-6h10v20z"></path>
4     </symbol>
5 </svg>

3. Insert the copy button into the container where you want to copy the text content.

01 <div class="item-to-copy">
02   <div class="text-to-copy">
03     <h2>Nick Blair </h2>
04     <strong>95 Netus Rd. </strong><br>
05     Sedalia Utah 53700 <br />
06     (252) 848-9710
07   </div>
08   <button class="copy" data-text="COPY" data-text-copied="COPIED">
09     <svg class="icon icon-copy">
10       <use xlink:href="#icon-copy"></use>
11     </svg>
12     <span>COPY</span>
13   </button>
14 </div>

4. Initialize the copy to clipboard plugin and done.

1 $('button').copiq({
2   parent: '.item-to-copy',
3   content: '.text-to-copy'
4 });

5. All default plugin options & callback functions.

1 $('button').copiq({
2   parent: 'body',
3   content: '',
4   onSuccess: function () {},
5   onError: function () {}
6 });

This awesome jQuery plugin is developed by melbon. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net