码迷,mamicode.com
首页 > 移动开发 > 详细

移动端 点击 复制到剪贴版

时间:2019-12-20 11:51:34      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:ext   display   range   his   man   body   复制   one   select   

$(‘.copy‘).click(function(){
  var text=$(this).prev().children().text()
  const input = document.createElement(‘input‘);
  input.setAttribute(‘readonly‘,‘readonly‘);
  input.setAttribute(‘value‘,text);
  document.body.appendChild(input);
  input.setSelectionRange(0, 9999);
  if (document.execCommand(‘copy‘)) {
    input.select()
    document.execCommand(‘copy‘);
  }
  document.body.removeChild(input);
  $(‘.clipBoard_notice‘).css(‘display‘,‘block‘)
  clearTimeout(this.delay)
  this.delay=setTimeout(function(){
    $(‘.clipBoard_notice‘).css(‘display‘,‘none‘)
  },2000)
})

移动端 点击 复制到剪贴版

标签:ext   display   range   his   man   body   复制   one   select   

原文地址:https://www.cnblogs.com/luoshida/p/12071867.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!