---- AI试用 ---域名问题某些图片和js资源无法访问,导致一些代码实例无法运行!(代码里gzui.net换成momen.vip即可)

js(jq)复制内容到剪贴板

javascript 蚂蚁 7014℃ 0评论

在网上看了好多资料都没做出来,后来才发现要在服务器环境下才行 ,坑爹货!!!

<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script type="text/javascript" src="ZeroClipboard.js"></script>
<input type="text" name="" id="fe_text" class="form-control" value="http://www.gzui.net" />
<button type="button" class="btn btn-primary clip_button" data-dismiss="modal" >复制链接</button>
<script type="text/javascript">
      var client = new ZeroClipboard( $('.clip_button') );

      client.on( 'ready', function(event) {
        // console.log( 'movie is loaded' );

        client.on( 'copy', function(event) {
          event.clipboardData.setData('text/plain', $('#fe_text').val());
        } );

        client.on( 'aftercopy', function(event) {
          console.log('Copied text to clipboard: ' + event.data['text/plain']);
        } );
      } );

      client.on( 'error', function(event) {
        // console.log( 'ZeroClipboard error of type "' + event.name + '": ' + event.message );
        ZeroClipboard.destroy();
      } );
    </script>

github项目地址

转载请注明:有爱前端 » js(jq)复制内容到剪贴板

喜欢 (10)or分享 (0)

(3)个小伙伴在吐槽
  1. https://github.com/zenorocha/clipboard.js/
    蚂蚁2016-04-27 13:41
  2. http://www.cnblogs.com/PeunZhang/p/3324727.html
    蚂蚁2017-04-05 13:09
  3. 复制内容到剪贴板 https://note.momen.vip/share?shareId=637de0d87c75c19ff166aa7b
    蚂蚁2022-12-06 17:31