2023-12-18 13:12:25 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
2024-01-16 21:26:16 +08:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8" />
|
2023-12-18 13:12:25 +08:00
|
|
|
<title>constructor-node</title>
|
2024-01-16 21:26:16 +08:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
</head>
|
|
|
|
<body>
|
2023-12-18 13:12:25 +08:00
|
|
|
<!-- 1. Define some markup -->
|
|
|
|
<div id="btn" data-clipboard-text="1">
|
2024-01-16 21:26:16 +08:00
|
|
|
<span>Copy</span>
|
2023-12-18 13:12:25 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 2. Include library -->
|
|
|
|
<script src="../dist/clipboard.min.js"></script>
|
|
|
|
|
|
|
|
<!-- 3. Instantiate clipboard by passing a HTML element -->
|
|
|
|
<script>
|
2024-01-16 21:26:16 +08:00
|
|
|
var btn = document.getElementById('btn');
|
|
|
|
var clipboard = new ClipboardJS(btn);
|
2023-12-18 13:12:25 +08:00
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
clipboard.on('success', function (e) {
|
|
|
|
console.info('Action:', e.action);
|
|
|
|
console.info('Text:', e.text);
|
|
|
|
console.info('Trigger:', e.trigger);
|
|
|
|
});
|
2023-12-18 13:12:25 +08:00
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
clipboard.on('error', function (e) {
|
|
|
|
console.info('Action:', e.action);
|
|
|
|
console.info('Text:', e.text);
|
|
|
|
console.info('Trigger:', e.trigger);
|
|
|
|
});
|
2023-12-18 13:12:25 +08:00
|
|
|
</script>
|
2024-01-16 21:26:16 +08:00
|
|
|
</body>
|
2023-12-18 13:12:25 +08:00
|
|
|
</html>
|