移動(dòng)端點(diǎn)擊按鈕復(fù)制文本內(nèi)容,具體內(nèi)容如下所示:
<div><p>邀請(qǐng)碼</p>//<p id="inviteCode" class="inviteCode">{{invite_code}}</p><input id="inviteCode" class="inviteCode" type="text" /><p class="copy">復(fù)制</p></div>copy() {var Url2 = this.invite_code;//var oInput = document.createElement("input");var oInput = document.getElementById("inviteCode");//oInput.value = Url2;// document.body.appendChild(oInput);oInput.select();// 選擇對(duì)象//document.execCommand("Cut","false",null);// 執(zhí)行瀏覽器剪切命令document.execCommand("Copy");// 執(zhí)行瀏覽器復(fù)制命令//oInput.className = "oInput";//oInput.style.display = "none";alert("復(fù)制成功");//console.log(document.execCommand("Copy"))},
總結(jié)
以上所述是小編給大家介紹的JS實(shí)現(xiàn)移動(dòng)端點(diǎn)擊按鈕復(fù)制文本內(nèi)容,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
新聞熱點(diǎn)
疑難解答