1. 程式人生 > >JS點選複製文字

JS點選複製文字

html

1 <p>邀請碼:<i>999999999999</i> <span class="copys">複製</span> </p>
2             <textarea rows="" style="display:none" cols="">999999999999</textarea>
1         $(".copys").on("touchstart", function() {
2             $('textarea').select();
3             document.execCommand("Copy");
4 alert("複製成功!"); 5 });