实现复制

实现复制

1
2
3
4
5
6
7
8
9
10
11
12
<body>
<input type="text" value="你好,我能被复制">
<button>点击复制</button>
<script>
document.querySelector("button").addEventListener('click', function () {
// 1. 获取input,并选择它
document.querySelector("input").select();
// 2. 执行copy命令
document.execCommand("copy");
})
</script>
</body>

实现复制
http://example.com/2023/05/25/UserScript-实现复制/
许可协议