mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Demo. The example of a link as an active element
Signed-off-by: Alex Ivanov <ai@contributor.pw>
This commit is contained in:
parent
44df750c9f
commit
2e2dcbd285
28
demo/text-programmatic-link-copy.html
Normal file
28
demo/text-programmatic-link-copy.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>text-programmatic-copy</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- 1. Define some markup -->
|
||||
<a href="#" id="btn">
|
||||
Copy
|
||||
</a>
|
||||
|
||||
<!-- 2. Include library -->
|
||||
<script src="../dist/clipboard.min.js"></script>
|
||||
|
||||
<!-- 3. Instantiate clipboard -->
|
||||
<script>
|
||||
var btn = document.querySelector('#btn');
|
||||
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const textCopied = ClipboardJS.copy('123');
|
||||
console.log('copied!', textCopied);
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user