Click achieved by copying clipboard

Reference material

clipboard Description:

  clipboard is a small JS framework, we only need to script , which is incorporated, you can use the copy function that provides the label.

 

Method a: The value to be copied on the data-clipboard-text , a click on the tab when the value will be copied to the clipboard

< Script the src = "https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" > </ Script > 
< Button Data-Clipboard-text = "text on the clipboard text copy achieve " class =" BTN-. 1 " > 
    click copy (clipboard text in the text to achieve replication) 
</ Button > 
< Script > 
    var Clipboard =  new new ClipboardJS ( ' .btn-. 1 ' ); // first examples of 
    clipboard.on ( ' Success ' ,function(e) {
        alert('Copied successfully ' ); // copy successful events 
    }); 
    clipboard.on ( ' error ' , function (E) { 
        Alert ( ' copy failure ' ); // replication is failing 
    });
 </ Script >

Method two: by data-clipboard-target from another copy text element








     To instantiate 
    clipboard.on ( ' Success ' , function (E) { 
        Alert ( ' successfully copied 2 ' ); // copy successful events 
    }); 
    clipboard.on ( ' error ' , function (E) { 
        Alert ( ' replication fails 2 ' ); // replication is failing 
    });
 </ Script >

Guess you like

Origin www.cnblogs.com/GetcharZp/p/12162953.html