$('点击对象').on('click',function(){
copyUrl($(this));
});
function copyUrl (obj){
if($('#urlText').length == 0){
// 创建input
obj.after('<input id="urlText" style="position:fixed;top:-200%;left:-200%;" type="text" value=' + window.location.href + '>');
}
$('#urlText').select(); //选择对象
document.execCommand("Copy"); //执行浏览器复制命令
}
网友评论