jQuery zclipboard Uncaught TypeError:Object [object HTMLAnchorElement]没有方法'data'

时间:2013-08-23 03:09:34

标签: javascript jquery content-management-system zclip

尝试让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);

1 个答案:

答案 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>