移動端複製黏貼

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());
});
相關文章
相關標籤/搜索