clipboard.js/demo/target-input.html

38 lines
890 B
HTML
Raw Normal View History

2015-10-27 08:53:03 +03:00
<!DOCTYPE html>
<html lang="en">
2021-01-20 18:55:03 +03:00
<head>
<meta charset="UTF-8" />
2015-10-27 08:53:03 +03:00
<title>target-input</title>
2021-01-20 18:55:03 +03:00
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
2015-10-27 08:53:03 +03:00
<!-- 1. Define some markup -->
2021-01-20 18:55:03 +03:00
<input id="foo" type="text" value="hello" />
<button
class="btn"
data-clipboard-action="copy"
data-clipboard-target="#foo"
>
Copy
</button>
2015-10-27 08:53:03 +03:00
<!-- 2. Include library -->
<script src="../dist/clipboard.min.js"></script>
<!-- 3. Instantiate clipboard -->
<script>
2021-01-21 13:45:33 +03:00
var clipboard = new ClipboardJS('.btn');
2015-10-27 08:53:03 +03:00
2021-01-21 13:45:33 +03:00
clipboard.on('success', function (e) {
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);
2021-01-20 18:55:03 +03:00
});
2015-10-27 08:53:03 +03:00
2021-01-21 13:45:33 +03:00
clipboard.on('error', function (e) {
2015-10-27 08:53:03 +03:00
console.log(e);
2021-01-20 18:55:03 +03:00
});
2015-10-27 08:53:03 +03:00
</script>
2021-01-20 18:55:03 +03:00
</body>
2015-10-27 08:53:03 +03:00
</html>