0

Zclip 插件不复制文本。

    <head>
    <script type = "text/javascript" src = "jquery.min.js"></script>
    <script type = "text/javascript" src = "jquery.zclip.min.js"></script>
</head>
<button id = "copy-description">132</button>
<p id = "description">123456789132456789</p>
<script type = "text/javascript">
$(document).ready(function(){
    $('#copy-description').click(function(){
        $('#copy-description').zclip({
            path:'ZeroClipboard.swf',
            copy:function(){return $('p#description').val();}

        });
    });
});
</script>

当我点击按钮时,我的剪贴板不会改变。我尝试使用 jQuery v1.11.1 和 v 1.6 感谢您的帮助。

4

1 回答 1

1

http://jsfiddle.net/LNd6p/

这应该有效。我摆脱id了 HTML 中标签的空间。

<button id="copy-description">132</button>
<p id="description">123456789132456789</p>

然后更改.val().text()因为我们从 div 而不是表单元素获取文本。

$(document).ready(function(){
    $('#copy-description').click(function(){
        $('#copy-description').zclip({
            path:'http://ajax.cdnjs.com/ajax/libs/zclip/1.1.2/ZeroClipboard.swf', //you can change this back to your local version, I had to to this for testing.
            copy:function(){
                return $('#description').text(); //changed .val() to .text()
            } 
        });
    });
});
于 2014-06-19T19:22:41.570 回答