当前位置: 移动技术网 > IT编程>开发语言>JavaScript > js 复制粘贴

js 复制粘贴

2018年04月23日  | 移动技术网IT编程  | 我要评论

input输入框
<div id="top-title" style="position: relative">
<img class="img-responsive center-block" alt="" src="" style="float:left;z-index: 999;position: absolute">
<input type="text" value="" id="awardQqQun1" style="float:left;z-index: 99;position: absolute">
<input type="text" value="" id="awardQqQun2" style="float:left;z-index: 99;position: absolute">
</div>
按钮
<button id="qqQunCopyBtn1" type="button" style="margin-top:5px;">点击复制群号</button>

给button添加一个事件
$("#qqQunCopyBtn1").on('click',function(){
var e=document.getElementById("awardQqQun1");//对象是content
e.select(); //选择对象
document.execCommand("Copy"); //执行浏览器复制命令
alert("群号复制成功");
});

 

该方法只能复制input里面的内容

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网