使用开源插件clipboard.js,示例代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/clipboard.js"></script>
<style>
#container{
position: relative;
width: 100px;
}
#copybtn{
position: absolute;
top:0;
left:0;
right:0;
width:100%;
height: 40px;
background: white;
}
#content{
width:90%;
height: 30px;
}
</style>
</head>
<body>
<div id="container"> <textarea id="content">文本</textarea>
<button id="copybtn" data-clipboard-action="copy" data-clipboard-target="#content"> 复制</button></div>
<script>
var clipboard = new Clipboard('#copybtn');
clipboard.on('success', function (e) {
alert("yes");
});
clipboard.on('error', function (e) {
alert("no");
});
</script>
</body>
</html> 网友回复
如何让ai帮我自动在小红书或抖音上自动根据需求截流与潜在客户聊天拉客?
如果用go编写一个在virtualbox中启动的简单操作系统?
go如何搭建一个零信任网络?
如何用python实现一个公网代理访问软件?
如何用go实现一个公网代理访问软件?
如何用python实现一个内网穿透打洞程序,实现内网的80端口暴露到公网上可以访问?
如何用go实现一个内网穿透打洞程序,实现内网的80端口暴露到公网上可以访问?
何为Shadowsocks 代理?
python如何实现类似php的opendir目录相互隔离的fastcgi多租户虚拟空间?
nodejs如何实现类似php的opendir目录相互隔离的fastcgi多租户虚拟空间?


