js实现复制

<body>
		<button onclick="copy()">复制</button>
		<textarea name="txarea" id="txarea" cols="105" rows="11" class="transform">复制内容</textarea>
</body>

<script type="text/javascript">
		function copy(){
			var e = document.getElementById("txarea");
			e.select(); // 选择对象
			document.execCommand("Copy"); // 执行浏览器复制命令
			alert("复制链接成功!");
		}
		

</script>
原文地址:https://www.cnblogs.com/AbbyXie/p/11525876.html