We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
第170天 用js实现一个复制粘贴的功能
核心代码应该就是
obj.select();//通过选中对象再执行复制命令 document.execCommand("Copy")
; (function () { const createInput = html => { let inputEl = document.createElement('input'); inputEl.setAttribute('type', 'input'); inputEl.value = html; return inputEl; } var key = '¥5uA302Tea83¥'; var inputEl = createInput(key); document.body.appendChild(inputEl) inputEl.select(); document.execCommand('copy') })();
var btn = document.getElementById('btn') btn.addEventListener('click', function() { input.select() document.execCommand('copy') })
Activity
wwqin commentedon Oct 3, 2019
核心代码应该就是
vkboo commentedon Oct 3, 2019
xiaoqiangz commentedon Aug 3, 2022
var btn = document.getElementById('btn')
btn.addEventListener('click', function() {
input.select()
document.execCommand('copy')
})