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