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