html点击复制兼容clipboard
(参考自 https://clipboardjs.com/)
<input id="foo" value="13456"> <button class="btn" data-clipboard-target="#foo"> <img src="assets/clippy.svg" alt="Copy to clipboard"> </button>
<script src="clipboard.min.js"></script> <script> var clipboard = new ClipboardJS('.btn'); clipboard.on('success', function(e) { console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigger); e.clearSelection(); }); clipboard.on('error', function(e) { console.error('Action:', e.action); console.error('Trigger:', e.trigger); }); </script>
posted on 2018-10-26 10:51 makeinchina 阅读(199) 评论(0) 编辑 收藏 举报