Aeroplankton Enthusiasts Society

Intangible Products for an Ephemeral World

Copy to Clipboard using jQuery & zClip

For a recent project I needed to copy the HTML content of a chosen element to the client’s clipboard upon request; making it possible for the user to easily transfer large sections of HTML between applications. Borrowing an awesome little jQuery & Flash (jQuery ZeroClipboard) snippit from SteamDev, I was able to quickly create a toolbar of links which would copy the HTML content of an element with a matching CSS class:



Links contained in the #copylinks div will have the zClip function applied to them. Each link should be given an #id matching the .class of it’s associated element/content.

The JavaScript/jQuery

Include the zClip library then loop through the links in the #copylinks div applying the zclip() function to each by their #id. Upon click the element with matching #div is copied to the client’s clipboard (with notice).

© 2018 Aeroplankton Enthusiasts Society, All rights reserved.