利用execCommand复制文本

//复制粘贴
var text =  $(this).text();
console.log('text:'+text);
var target = document.createElement("textarea");
target.style.position = "absolute";
target.style.left = "-9999px";
target.style.top = "0";
target.innerHTML = text;
document.body.appendChild(target);
target.select(); // 选中文本
document.execCommand("copy"); // 执行浏览器复制命令
layer.msg("复制成功");


鼎云博客
  • 最新评论
  • 总共0条评论