<a style='text-decoration: none' onclick='copyText(this)' >复制文本</a>
<input type="text" id="copy" />
function copyText(obj) {
var text = obj.innerText;
if (text == "") {
return false;
}
var input = document.getElementById("copy");
input.value = text;
input.select();
document.execCommand("copy");
$.modalMsg("文本复制成功");
}
注意: input不能设置成hidden,不能带disabled属性,也不能隐藏。