代码语言:javascript复制
<div>
<input type="button" value="复制"
"var selectText = window.getSelection();var obj=document.getElementById('txt');
obj.innerHTML=selectText;obj.select();document.execCommand('Copy');">
<textarea id="txt" rows="6" cols="40"></textarea>
</div>
通过代码段获取