jquery复制链接(复制Url链接)

2019-11-25  本文已影响0人  leleo
$('点击对象').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"); //执行浏览器复制命令
  }
上一篇 下一篇

猜你喜欢

热点阅读