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("已複製到剪下板");
})
複製程式碼
execCommand 相容
