87,914
社区成员
发帖
与我相关
我的任务
分享
<input type="submit" value="复制">
点击上面这个复制按钮,会自动复制这句话
“啊我二哥我哥微服私访的”
如何实现
<textarea style="width:200px;height:50px;" id="str">啊我二哥我哥微服私访的</textarea>
<input type="button" onclick="copyText()" value=" 复制 "/>
<script type="text/javascript">
function copyText(){
var v = document.getElementById("str");
if(v.value.length>0){
v.select();
document.execCommand("Copy");
alert('已经复制到剪贴板!');
return false;
}
}
</script>