在网上看了好多资料都没做出来,后来才发现要在服务器环境下才行 ,坑爹货!!!
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script type="text/javascript" src="ZeroClipboard.js"></script>
<input type="text" name="" id="fe_text" class="form-control" value="http://www.gzui.net" /> <button type="button" class="btn btn-primary clip_button" data-dismiss="modal" >复制链接</button>
<script type="text/javascript">
var client = new ZeroClipboard( $('.clip_button') );
client.on( 'ready', function(event) {
// console.log( 'movie is loaded' );
client.on( 'copy', function(event) {
event.clipboardData.setData('text/plain', $('#fe_text').val());
} );
client.on( 'aftercopy', function(event) {
console.log('Copied text to clipboard: ' + event.data['text/plain']);
} );
} );
client.on( 'error', function(event) {
// console.log( 'ZeroClipboard error of type "' + event.name + '": ' + event.message );
ZeroClipboard.destroy();
} );
</script>
转载请注明:有爱前端 » js(jq)复制内容到剪贴板
