first, load the Clipboard.js file (a CDN I'm looking for online):
<script src= "Https://cdn.rawgit.com/zenorocha/clipboard.js/master/dist/clipboard.min.js" ></script>
Second, the HTML code:
<input type= "text" value= "Http://suo.im/8p5iq id=" Onlineimgurl "/> <button id=" Copylink "class="
btn Btn-primary "class=" btn dropdown-toggle "data-clipboard-target=" #onlineImgUrl "aria-label=" replication Success "> Copy link </ Button>
Note:
The Data-clipboard-target property Description duplicates the value content in #onlineimgurl, and the value in my input box is empty because it is written dynamically.
The Aria-label property is used to prompt for a copy of the result information, which I would eject if replication succeeds.
Finally, JS code like this:
Copy link button
var clipboard = new Clipboard ('. btn ');
Clipboard.on (' Success ', function (e) {
var msg = e.trigger.getattribute (' Aria-label ');
Alert (msg);
});
Look at the effect chart:
Input box is a bit ugly ... Because the input box seems to be unable to achieve the length of the adaptive eh, temporarily let it ugly (⊙o⊙) Ah. Oh, my picture URL is compressed.
* Learn more look here
https://clipboardjs.com/
http://9iphp.com/web/javascript/js-copy-library-clipboard-js.html*