移动端复制黏贴

function Copy(str){
    var save = function(e){
        e.clipboardData.setData('text/plain', str);
        e.preventDefault();
    }
    document.addEventListener('copy', save);
    document.execCommand('copy');
    document.removeEventListener('copy',save);
    alert('复制成功!');
}
$('#cardList').on('click', 'div.btn', function(){
    Copy($(this).prev('div').find('span.code').text());
});

  

posted @ 2017-05-24 15:29  MauriceChans  阅读(194)  评论(0编辑  收藏  举报