| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="UTF-8" /> |
| 5 |
<title>constructor-node</title> |
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 7 |
</head> |
| 8 |
<body> |
| 9 |
<!-- 1. Define some markup --> |
| 10 |
<div id="btn" data-clipboard-text="1"> |
| 11 |
<span>Copy</span> |
| 12 |
</div> |
| 13 |
|
| 14 |
<!-- 2. Include library --> |
| 15 |
<script src="../dist/clipboard.min.js"></script> |
| 16 |
|
| 17 |
<!-- 3. Instantiate clipboard by passing a HTML element --> |
| 18 |
<script> |
| 19 |
var btn = document.getElementById('btn'); |
| 20 |
var clipboard = new ClipboardJS(btn); |
| 21 |
|
| 22 |
clipboard.on('success', function (e) { |
| 23 |
console.info('Action:', e.action); |
| 24 |
console.info('Text:', e.text); |
| 25 |
console.info('Trigger:', e.trigger); |
| 26 |
}); |
| 27 |
|
| 28 |
clipboard.on('error', function (e) { |
| 29 |
console.info('Action:', e.action); |
| 30 |
console.info('Text:', e.text); |
| 31 |
console.info('Trigger:', e.trigger); |
| 32 |
}); |
| 33 |
</script> |
| 34 |
</body> |
| 35 |
</html> |