完成复制链接功能


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>test</title>
</head>
<body>
        <input type="text" class="share-input"  value="http://www.youtube.com" id="copy-content"/>
        <button class="copy-button" type="button" onclick="copyContent();"> 复制 </button>
</body>
<script type="text/javascript">
    /*Copy function implementation */
       function copyContent(){ 
       var copyobject=document.getElementById("copy-content");
       copyobject.select();
       document.execCommand("Copy");
       alert("已复制成功哦~"); 
   };
</script>
</html>

猜你喜欢

转载自blog.csdn.net/qq_38932474/article/details/103530148
今日推荐