jquery Implementation click Copy to Clipboard

Source: Internet
Author: User

1. A jquery library must be introduced first

<script type= "Text/javascript" src= "js/jquery.js" ></script><script type= "Text/javascript" src= "js/ Jquery.zclip.min.js "></script>

2.js Implement click-To-Copy code

<script type= "Text/javascript" >    $ (function () {    $ (' #copy_input '). Zclip ({  //copy_input means the button path: '  Zeroclipboard.swf ', copy:function () {//Copy contents    return $ (' #mytext '). Val (); MyText represents content},aftercopy:function () {//Copy Success    //$ ("<span id= ' msg '/>"). InsertAfter ($ (' #copy_input ')). Text ( ' Replication success ');    Alert (' Copy succeeded ');}    ); </script>

3. Configuration Instructions
path:swf path (replication mainly uses Flash to resolve different browser replication)
Copy: What you want to copy, either static or return dynamic content
Beforecopy: The function to be done before copying;
Aftercopy: function to be done after copying;

4.3 methods are available
Show:$ (selected). Zclip (' show '); copy function valid
Hide:$ (selected). Zclip (' hide '); Invalid copy function
Remove:$ (selected). Zclip (' remove '); Complete removal of replication functionality

5. After successful operation, click the Copy button and a prompt will pop up indicating that the copy to the Clipboard is in effect. Pop-up box appears "Copied Text to Clipboard" English characters, a bit inconsistent with the Chinese people use the habit, change it to "successfully copied to the Clipboard", in the Jquery.zclip.min.js file found "Copied text to clipboard" replaced by "Successfully copied to the Clipboard" will be OK.

Note: When there is a aftercopy () function to handle the successful action, there will be no fifth-step frame.

6. File to be placed in the server to run, directly run the HTML file is not

jquery Implementation click Copy to 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.