可以实现一键复制需要的字段。
HTML页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script src="js/clipboard.js"></script>
<style>
.tips,.tipsbg{display: none;}
.tipsbg{width: 100%;height: 100%;position: fixed;background: rgba(0, 0, 0, 0.3); top: 0px; left: 0px; right: 0px; bottom: 0px;z-index: 2;}
.tips{width: 160px;height: 200px;position: fixed;background: rgba(0, 0, 0, 0.5); top: 0px; left: 0px; right: 0px; bottom: 0px;z-index: 3;margin: 200px auto 0 auto;border-radius: 10px;}
.tips img{width: 80px;margin: 30px auto;display: block;}
.tipssuc{width: 100%;height: 40px;line-height: 40px;text-align: center;color: #fff;font-size: 16px;}
.sidebar{width:30px;position:fixed;top:300px;left:50%;margin-left:-555px;z-index:9}
.sidebar a {width: 42px;padding: 13px 0;color: #666;background: #fff;-webkit-box-shadow:0px 2px 15px 0px rgba(0,0,0,0.1);box-shadow: 0px 2px 15px 0px rgba(0,0,0,0.1);border-radius: 21px;text-align: center;transition: all .2s cubic-bezier(.215,.61,.355,1);position: relative;cursor: pointer;margin-bottom:15px;display: block;text-decoration:none;}
.sidebar span {font-size: 13px;display: block;padding: 0 12px;line-height: 17px;}
.sidebar a:hover{background-color:#478ede; text-decoration:none;color:#fff;-webkit-box-shadow:0px 0px 10px 0px rgba(0,0,0,0.3);box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.3);}
</style>
</head>
<body>
<div id="docopy" class="content">
alskdjf
</div>
<div class="tipsbg" onclick="$('.tips').hide();$('.tipsbg').hide();"></div>
<div id="success" class="tips" onclick="$('.tips').hide();$('.tipsbg').hide();">
<img src="images/cg.png" alt="">
<div class="tipssuc">复制成功</div>
</div>
<div class="sidebar">
<a id="copytext" data-clipboard-action="copy" data-clipboard-target="#docopy" class="fuzhi"><span>一键复制</span></a>
</div>
<script>
$(document).ready(function () {
var clipboard = new ClipboardJS('#copytext');
clipboard.on('success', function (e) {
$('#success').show();
$('.tipsbg').show();
});
});
</script>
</body>
</html>
JS+html打包下载地址:
1649611865-12cba3ee81cf4a7.rar
效果演示:http://dhg1.cncobo.com/dhg100z/5216.html
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:115904045@qq.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明。