Click copy content to clipboard)

Source: Internet
Author: User

Clipboard official documentation: https://clipboardjs.com/

Installation:

1. Run NPM: NPM install clipboard -- save

2. Download: https://github.com/zenorocha/clipboard.js/archive/master.zip

Usage:

1. Copy content from other components:

 
<! -- Target --> <input id = "foo" value = "https://github.com/zenorocha/clipboard.js.git"> <! -- Trigger --> <button class = "BTN" data-clipboard-target = "# foo">  </button>

2. Cut other components:

<! -- Target --> <textarea id = "bar"> mussum ipsum cacilds... </textarea> <! -- Trigger --> <button class = "BTN" data-clipboard-action = "cut" data-clipboard-target = "# bar">Cut to clipboard </button>

3. Copy the self-built content:

 
<! -- Trigger --> <button class = "BTN" data-clipboard-TEXT = "just because you can doesn't mean you shocould-clipboard. js">Copy to clipboard </button>

Event:

 
VaR clipboard = new clipboardjs ('. BTN'); Clipboard. On ('success', Function(E) {console.info ('Action :', E. Action); lele.info ('text :', E. Text); lele.info ('triggers :', E. Trigger); E. clearselection () ;}); clipboard. On ('error', Function(E) {console. Error ('Action :', E. Action); console. Error ('triggers :', E. Trigger );});

click Copy content to the clipboard

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.