Home  >  Article  >  Web Front-end  >  Implementation method of zeroclipboard single copy button and multiple copy buttons_javascript skills

Implementation method of zeroclipboard single copy button and multiple copy buttons_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:44:471946browse

Zeroclipboard is a cross-browser library class that uses Flash for copying, so it can run as long as the browser has Flash installed, and is more flexible than IE's document.execCommand("Copy").

zeroclipboard download address: http://www.jb51.net/jiaoben/24961.html

zeroclipboard implements multi-browser copy to pasteboard function (single copy button and multiple copy buttons). For a better user experience, the content of text boxes in many websites now only needs to click the copy button, so that the content can be copied to Paste board;

For compatibility reasons, it is basically implemented through zeroclipboard. First, download zeroclipboard, unzip and put ZeroClipboard.js, ZeroClipboard.swf, and ZeroClipboard10.swf ("for flash10") into the project. You can Load swf through ZeroClipboard.setMoviePath( '/ZeroClipboard.swf' ) method;
The following is the compiled code (also compiled through online search)

(single copy button):

html:

Copy code The code is as follows:

Copy


Multiple copy buttons:

Copy code The code is as follows:
copy
Copy
Copy


Note: clip.setText( $("#copy_txt" id).val() ); If you want to get the content in a div, generally use clip.setText( $("#copy_txt" id).text() ) ;or clip.setText( $("#copy_txt" id).html() );

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn