必须是input或者是textarea
<input type="hidden" id="copy1" value="我是要复制的内容">
<textarea cols="20" rows="10" id="copy1" style="position: fixed;top: -2000px;">我是要复制的内容</textarea>
<button onclick="copyContent('copy1')">复制</button>
js
function copyContent(id){
var copyCon = document.getElementById(id);
copyCon.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
alert("已复制好,可贴粘。");
}