Skip to content

Instantly share code, notes, and snippets.

@Calerme
Created February 28, 2018 03:42
Show Gist options
  • Save Calerme/a5503d571833a8b016f8170a8fdc93f1 to your computer and use it in GitHub Desktop.
Save Calerme/a5503d571833a8b016f8170a8fdc93f1 to your computer and use it in GitHub Desktop.
JavaScript  复制内容到剪贴板
/* 使用 clipboard.js 库 */
btn.addEventListener('click', () => {
const input = document.querySelector('#demoInput');
input.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
console.log('复制成功');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment