

There are cases where you'd like to show some user feedback or capture what has been selected after a copy/cut operation. The value you include on this attribute needs to match another's element selector. You can do that by adding a data-clipboard-target attribute in your trigger element. Copy text from another elementĪ pretty common use case is to copy content from another element. We're living a declarative renaissance, that's why we decided to take advantage of HTML5 data attributes for better usability. But guess what? If you have hundreds of matches, this operation can consume a lot of memory.įor this reason we use event delegation which replaces multiple event listeners with just a single listener. Internally, we need to fetch all elements that matches with your selector and attach event listeners for each one. Now, you need to instantiate it by passing a DOM selector, HTML element, or list of HTML elements. Setupįirst, include the script located on the dist folder or load it from a third-party CDN provider.
Copied text to clipboard zip#
Or if you're not into package management, just download a ZIP file. But most of all, it shouldn't depend on Flash or any bloated framework. It shouldn't require dozens of steps to configure or hundreds of KBs to load. Just 3kb gzippedĬopying text to the clipboard shouldn't be hard. Clipboard.js - Copy to clipboard without Flash clipboard.js A modern approach to copy text to clipboard No Flash.
