http://www.cnblogs.com/huijieoo/articles/5569990.html
<script type="text/javascript" src="/static/js/ZeroClipboard.min.js"></script>
$(function(){ $("#game_id").change(function(){ changeGame($(this).val()); }); $.getJSON("?action=get_serverlist",function(data){ serverlist_json = data; //$("#game_id").get(0).selectedIndex=0; //$("#server_id").get(0).selectedIndex=0; }); //表格隔行换色 //$(".linktable tr:even").css("background-color","#eeeeee"); $(".copybtn").click(function(){ var clip = new ZeroClipboard($(this)[0]); clip.on("ready", function(readyEvent) { clip.on("aftercopy", function(event) { alert("复制成功,地址为: " + event.data["text/plain"]); }); }); }); //由于第一次点击无效,故加载时先触发一次。 $(".copybtn").click(); });
{foreach $link_list as $link} <tr> <td width="30" align="center"><input type="checkbox" name="link_id[]" value="{$link.id}" /></td> <td height="30" width="120" align="center">{$link.gamename}</td> <td >{$link.servername}</td> <td >{$link.url}</td> <td >0</td> <td >0</td> <td width="60" align="center"><a data-clipboard-text="{$link.url}" class="copybtn" href="javascript:void(0)">复制</a> </td> </tr> {foreachelse} <tr><td height="50" colspan="8" align="center">暂时没有数据哦!</td></tr> {/foreach}