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>function-text</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 -->
|
|
|
|
<button class="btn">Copy</button>
|
|
|
|
|
|
|
|
<!-- 2. Include library -->
|
|
|
|
<script src="../dist/clipboard.min.js"></script>
|
|
|
|
|
|
|
|
<!-- 3. Instantiate clipboard -->
|
|
|
|
<script>
|
2024-01-16 21:26:16 +08:00
|
|
|
var clipboard = new ClipboardJS('.btn', {
|
|
|
|
text: function () {
|
|
|
|
return 'to be or not to be';
|
|
|
|
},
|
|
|
|
});
|
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>
|