html:
<div id="div">
<p>我的推广链接:</p>
<input id="input1" value="sdgafg" onclick="copyUrl(id)" readonly/>
<input id="input2" value="gafg" onclick="copyUrl(id)" readonly/>
<input id="input3" value="sg" onclick="copyUrl(id)" readonly/>
</div>
js:
<script>
function copyUrl(id) {
var Url=document.getElementById(id);
Url.select(); // 选择对象 input标签才有select()方法
document.execCommand("Copy"); // 执行浏览器复制命令
}
</script>
网友评论