1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > html+jquery 复制内容到粘贴板

html+jquery 复制内容到粘贴板

时间:2024-05-20 10:58:23

相关推荐

html+jquery 复制内容到粘贴板

方法一

<textareaid="copy"style="display:none;"></textarea><script>$(".copy-btn").click(function(){//console.log(1111111);varstr="xxxxxx";$('#copy').text(str).show();varele=document.getElementById("copy");ele.select();document.execCommand('copy',false,null);$('#copy').hide();alert('邮箱复制成功!');})

方法二

var copy_txt=function(){//无组件复制var _this =this;this.copy=function(txt){$("#input_copy_txt_to_board").val(txt);//赋值$("#input_copy_txt_to_board").removeClass("hide");//显示$("#input_copy_txt_to_board").focus();//取得焦点$("#input_copy_txt_to_board").select();//选择document.execCommand("Copy");$("#input_copy_txt_to_board").addClass("hide");//隐藏}//-----------let html ='<input type class="hide" id="input_copy_txt_to_board" value="" />';//添加一个隐藏的元素$("body").append(html);}function copyUrl(url){//使用方法var ct =new copy_txt();ct.copy(url);//把"xxx"复制到粘贴板$.show_success("复制成功!");}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。