js复制div块的文本信息

js复制div块的文本信息

代码

function copyOrderDivData(obj){
    var id = $(obj).attr("data");
    var orderDivInnerText=document.getElementById(id).innerText;
    var newInput = document.createElement('input');
    newInput.setAttribute('value',orderDivInnerText.split(':')[1]);
    document.body.appendChild(newInput);
    newInput.select();
    document.execCommand("copy");
    document.body.removeChild(newInput);
    alert('Copy Success!')
    return false;
}
posted @ 2022-07-22 14:08  努力跟上大神的脚步  阅读(393)  评论(0编辑  收藏  举报