How to copy text from php file to clipboard using jquery

Hey Pal,

Worried about copying text/link to clipboard? No worries dude..its mere simple as switching a light on 😉

There are many ways to achieve this concept..how ever i followed zclip..

Download zclip.js from this link

Place <script src=”js/jquery.zclip.js”/></script> in head tag

HTML:

<a href=”” data-copy=”<?php echo $v;?>” class=”copy” class=”list-group-item”><?php
print “$v”; ?></a>

Script:

<script>
$(“a.copy”).on(‘click’, function (e) {
e.preventDefault();
}).each(function () {
$(this).zclip({
path: ‘http://www.steamdev.com/zclip/js/ZeroClipboard.swf&#8217;,
copy: function() {
return $(this).data(‘copy’);
}
});
});
</script>

Now execute your code..you can see an alert showing your copied text to clipboard. Enjoy 😉

Get complete zeroclipboard from github

References:

http://jsfiddle.net/Vr4Ky/180/

http://stackoverflow.com/questions/14235324/jquery-zclip-copy-to-clipboard-for-multiple-links-in-bootstrap-dropdown

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s