//原生copy, 入参为 id 属性的值
function copy(data) {
let text = $("#" + data).val();
var input = document.createElement(‘input‘);
input.setAttribute(‘readonly‘, ‘readonly‘);
input.setAttribute(‘value‘, text);
document.body.appendChild(input);
input.select();
input.setSelectionRange(0, 9999);
document.execCommand(‘Copy‘);
layer.msg(‘复制成功!‘,{icon: 1, offset: ‘210px‘});
}
原文:https://www.cnblogs.com/RenChenHao/p/14752953.html