之前只能用flash來粘貼,太麻煩。
github就不用flash也能粘貼,參考例子:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Copy測試頁面</title>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
</head>
<body>
<!-- Target -->
<input id="foo" value="https://github.com/zenorocha/clipboard.js.git">
<!-- Trigger -->
<button class="btn" data-clipboard-target="#foo">
Copy to clipboard
</button>
<script>
new ClipboardJS('.btn');
</script>
</body>
</html>