0

试图让 zclip 工作:

jQuery(document).ready(function($){

$('.copy').zclip({
    path:'http://www.steamdev.com/zclip/js/ZeroClipboard.swf',
    copy:function(){return $('.macro').val();}
});

// The link with ID "copy-dynamic" will copy the current value
// of a dynamically changing input with the ID "dynamic"

});

现在我收到此错误:

Uncaught TypeError: Object [object HTMLAnchorElement] has no method 'data' @ jquery.zclip.js line 286

 $(this.domElement).data('zclipId', 'zclip-' + this.movieId);
4

1 回答 1

1

试试这个jsfiddle

将 jQuery 和 zClip 添加到您的文档中。

 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://cdn.strategiqcommerce.com/ajax/libs/zclip/1.1.1/jquery.zclip.min.js"></script> 

将 zClip 附加到将成为“复制按钮”的元素。

$(document).ready(function () {
$('.copy').zclip({
    path: 'http://cdn.strategiqcommerce.com/ajax/libs/zclip/1.1.1/ZeroClipboard.swf',
    copy: function () {
        return $('.macro').val();
    }
});
});

HTML 标记

<a href="#" class="copy">Copy</a>
<textarea rows=3 class="macro" placeholder="Type text that is to copied and click copy"></textarea>
<textarea rows=3 placeholder="Paste copied text and check"></textarea>
于 2013-08-23T04:20:40.840 回答