<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS复制功能</title>
<link href="" rel=" rel="external nofollow" stylesheet">
<style>
 *{
 margin:0;
 padding:0;
 }
 input{
 border:1px solid #ccc;
 padding: 5px;
 width: 200px;
 }
 button{
 height:32px;
 }
</style>
</head>
<body>
 <input type="text"placeholder="里面输入文字">
 <button type="button">点击复制</button>
 <script type="text/javascript" src='http://libs.baidu.com/jquery/2.0.0/jquery.js'></script>
 <script>
  $(document).ready(function(){
  $('button').click(function(){
  $('input').trigger('select');
  document.execCommand('copy');
  alert('复制成功')
  })
  })
 </script>
</body>
</html>


相关评论(0)
您是不是忘了说点什么?

友情提示:垃圾评论一律封号...

还没有评论,快来抢沙发吧!