1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="UTF-8" />
|
5 | <title>function-text</title>
|
6 | <meta name="viewport" content="width=device-width, initial-scale=1" />
|
7 | </head>
|
8 | <body>
|
9 |
|
10 | <button class="btn">Copy</button>
|
11 |
|
12 |
|
13 | <script src="../dist/clipboard.min.js"></script>
|
14 |
|
15 |
|
16 | <script>
|
17 | var clipboard = new ClipboardJS('.btn', {
|
18 | text: function () {
|
19 | return 'to be or not to be';
|
20 | },
|
21 | });
|
22 |
|
23 | clipboard.on('success', function (e) {
|
24 | console.log(e);
|
25 | });
|
26 |
|
27 | clipboard.on('error', function (e) {
|
28 | console.log(e);
|
29 | });
|
30 | </script>
|
31 | </body>
|
32 | </html>
|