target-input.html 890 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>target-input</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <!-- 1. Define some markup -->
  10. <input id="foo" type="text" value="hello" />
  11. <button
  12. class="btn"
  13. data-clipboard-action="copy"
  14. data-clipboard-target="#foo"
  15. >
  16. Copy
  17. </button>
  18. <!-- 2. Include library -->
  19. <script src="../dist/clipboard.min.js"></script>
  20. <!-- 3. Instantiate clipboard -->
  21. <script>
  22. var clipboard = new ClipboardJS('.btn');
  23. clipboard.on('success', function (e) {
  24. console.info('Action:', e.action);
  25. console.info('Text:', e.text);
  26. console.info('Trigger:', e.trigger);
  27. });
  28. clipboard.on('error', function (e) {
  29. console.log(e);
  30. });
  31. </script>
  32. </body>
  33. </html>