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



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

现在我得到这个错误:

未捕获的类型错误:对象[Object HTMLAnchorElement]没有方法"data"@jquery.zclip.js行286

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

试试这个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>

相关内容

  • 没有找到相关文章

最新更新