target-textarea.html 720 B

1234567891011121314151617181920212223242526272829
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>target-textarea</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. </head>
  8. <body>
  9. <!-- 1. Define some markup -->
  10. <textarea id="bar">hello</textarea>
  11. <button class="btn" data-clipboard-action="cut" data-clipboard-target="#bar">Cut</button>
  12. <!-- 2. Include library -->
  13. <script src="../dist/clipboard.min.js"></script>
  14. <!-- 3. Instantiate clipboard -->
  15. <script>
  16. var clipboard = new ClipboardJS('.btn');
  17. clipboard.on('success', function(e) {
  18. console.log(e);
  19. });
  20. clipboard.on('error', function(e) {
  21. console.log(e);
  22. });
  23. </script>
  24. </body>
  25. </html>