日期:2014-05-16 浏览次数:20467 次
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.zclip.js"></script>
<script type="text/javascript"><!--
$(document).ready(function(){
$('a#copy1').zclip({
path:'js/ZeroClipboard.swf',
copy:$('p#becopied1').text()
});
});
//-->
</script>
<a id="copy1">点击复制</a>
<p id="becopied1">被复制内容1</p>
$(document).ready(function(){
var copyButton = 'copy';
var textInput = 'becopied';
$('.copy').each(function(){//给每个a标签加上copy样式
var thisId = this.id.replace(copyButton,'');
$(this).zclip({
path:'js/ZeroClipboard.swf',
copy:$('p#becopied'+thisId).text()
})
})
});
<script>
$(function () {
$('a[rel]').zclip({ copy: function () { return $(this.getAttribute('rel')).html(); } });
});
</script>
<body>
<a rel="#p1">拷贝1</a>
<p id="p1">拷贝内容1拷贝内容1拷贝内容1</p>
<a rel="#p2">拷贝2</a>
<p id="p2">拷贝内容2<br />拷贝内容2</p>
<a rel="#p3">拷贝3</a>
<p id="p3">拷贝内容3<br />拷贝内容3</p>