html
<textarea cols="20" rows="10" id="tkl">
復(fù)制內(nèi)容
</textarea>
<input type="button" onClick="copyTkl()" value="復(fù)制" />
js
function copyTkl() {
const range = document.createRange();
range.selectNode(document.getElementById('tkl'));
const selection = window.getSelection();
if (selection.rangeCount > 0) selection.removeAllRanges();
selection.addRange(range);
document.execCommand('copy');
alert("復(fù)制淘口令成功......");
}