1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/clipboard/demo/function-target.html

38 lines
975 B
HTML
Raw Permalink Normal View History

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-target</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>
<div>hello</div>
<!-- 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', {
target: function () {
return document.querySelector('div');
},
});
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>