html
<textarea name="" id="copytest" readonly>一键复制至剪切版</textarea>
<input type="button" id="copy" value="复制">
复制代码
js
$(document).on("click","#copy",function(){
var copytest=$("#copytest");
copytest.select();
document.execCommand("copy");
alert("已复制到剪切板");
})
复制代码