1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="UTF-8" />
|
5 | <title>text-programmatic-copy</title>
|
6 | <meta name="viewport" content="width=device-width, initial-scale=1" />
|
7 | </head>
|
8 | <body>
|
9 |
|
10 | <button id="btn">
|
11 | Copy
|
12 | </button>
|
13 |
|
14 |
|
15 | <script src="../dist/clipboard.min.js"></script>
|
16 |
|
17 |
|
18 | <script>
|
19 | var btn = document.querySelector('#btn');
|
20 |
|
21 | btn.addEventListener('click', () => {
|
22 | const textCopied = ClipboardJS.copy('123');
|
23 | console.log('copied!', textCopied);
|
24 | })
|
25 | </script>
|
26 | </body>
|
27 | </html>
|