constructor-nodelist.html 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>constructor-nodelist</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <!-- 1. Define some markup -->
  10. <button data-clipboard-text="1">Copy</button>
  11. <button data-clipboard-text="2">Copy</button>
  12. <button data-clipboard-text="3">Copy</button>
  13. <!-- 2. Include library -->
  14. <script src="../dist/clipboard.min.js"></script>
  15. <!-- 3. Instantiate clipboard by passing a list of HTML elements -->
  16. <script>
  17. var btns = document.querySelectorAll('button');
  18. var clipboard = new ClipboardJS(btns);
  19. clipboard.on('success', function (e) {
  20. console.info('Action:', e.action);
  21. console.info('Text:', e.text);
  22. console.info('Trigger:', e.trigger);
  23. });
  24. clipboard.on('error', function (e) {
  25. console.info('Action:', e.action);
  26. console.info('Text:', e.text);
  27. console.info('Trigger:', e.trigger);
  28. });
  29. </script>
  30. </body>
  31. </html>