实现input框复制功能
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</script>
</head>
<body>
<input type="text" id="contents" /><br/>
<input type="button" onClick="copy()" value="复制" />
<script type="text/javascript">
function copy(){
var e=document.getElementById("contents");//对象是contents
e.select(); //选择对象
nice=document.execCommand("Copy"); //执行浏览器复制命令
if(nice){
alert('复制内容成功');
}
}
</script>
</body>
</html>
原文:https://blog.csdn.net/qq_42249896/article/details/86552338