一段js实现复制文本内容到剪切板
生活随笔
收集整理的這篇文章主要介紹了
一段js实现复制文本内容到剪切板
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<script type="text/javascript">
function copyUrl2(){var Url2=document.getElementById("biao1").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>
<div cols="20" id="biao1">12345678</div>
<input type="button" onClick="copyUrl2()" value="點擊復制代碼" />
更多專業前端知識,請上 【猿2048】www.mk2048.com
?
更多專業前端知識,請上 【猿2048】www.mk2048.com
總結
以上是生活随笔為你收集整理的一段js实现复制文本内容到剪切板的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: flex弹性布局操练2
- 下一篇: Selenium1 Selenium2