尝试让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]没有方法'data'@ jquery.zclip.js第286行
$(this.domElement).data('zclipId', 'zclip-' + this.movieId);
答案 0 :(得分: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>