function-text.html 709 B

1234567891011121314151617181920212223242526272829303132
  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. <!-- 1. Define some markup -->
  10. <button class="btn">Copy</button>
  11. <!-- 2. Include library -->
  12. <script src="../dist/clipboard.min.js"></script>
  13. <!-- 3. Instantiate clipboard -->
  14. <script>
  15. var clipboard = new ClipboardJS('.btn', {
  16. text: function() {
  17. return 'to be or not to be';
  18. }
  19. });
  20. clipboard.on('success', function(e) {
  21. console.log(e);
  22. });
  23. clipboard.on('error', function(e) {
  24. console.log(e);
  25. });
  26. </script>
  27. </body>
  28. </html>