84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
js怎样实现ctrl + c 的复制功能?
业精于勤,荒于嬉;行成于思,毁于随。
<html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .text-input{ border: none; outline:medium; box-shadow: none; } .copy-id:focus{ border: none; } </style> </head> <body> <input readonly="readonly" class="copy-id text-input" type="text" value="12333333333"/> <button class="copy">复制</button> </body> <script type="text/javascript" src="http://cdn.bootcss.com/jquery/2.2.3/jquery.min.js"></script> <script type="text/javascript"> $('.copy').click(function () { $('.copy-id').select(); document.execCommand("copy",false,null); }) </script> </html>
这是点击按钮,实现复制
<input type="text" id="input"> <button onclick="copyFn()">点击</button> <script> function copyFn() { var e = document.getElementById("input"); e.select(); document.execCommand("Copy"); } </script>
keydown getSelection
见楼上就可以
这是点击按钮,实现复制
见楼上就可以