//点击复制
<div class="userMenu_number">
<div class="userMenu_numItem clearfix">
<div class="userMenu_shareLink fl" id="userShare_code">wearable</div>
<div class="userLogin_place fl userMenu_copy point" onclick="copyUrl2('userShare_code')">复制</div>
</div>
</div>
<script>
function copyUrl2(id) {
var Url2 = document.getElementById(id).innerText;
var oInput = document.createElement('input');
oInput.value = Url2;
document.body.appendChild(oInput);
oInput.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
oInput.className = 'oInput';
oInput.style.display = 'none';
alert("复制成功");
}
</script>
网友评论