Search code examples
javascriptjqueryzeroclipboard

Copy to clipboard using Zclipboard.js not working


I tried Zclipboard.js for copying the value but it didn't work.

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.steamdev.com/zclip/js/jquery.zclip.min.js"></script>
<script>
$(document).ready(function(){
    $('#copy-description').zclip({
        path:'ZeroClipboard.swf',
        copy:$('#description').text()

    });
});
</script>
<a id="copy-description" href="#" class="">Copy</a>
<p id="description">This should copy</p>

I referred it from this link. I am just getting a copy link with flash player embedded in it. But I cannot click it. What should I change in code, so that I can copy the description text on clicking copy link


Solution

  • I think the problem might be the swf file. Try this. Hope it works

    $(document).ready(function(){
        $('#copy-description').zclip({
            path:'http://www.steamdev.com/zclip/js/ZeroClipboard.swf',
            copy:$('#description').text()
    
        });
    });