copy

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<link href="https://cdn.bootcss.com/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
	<title>	</title>
	<style>
		.hand{
			text-align: center;
			border-radius: 10px;
			width: 60px;
			height: 36px;
			line-height: 36px;
			
		}
		.hand:hover{
			cursor: pointer;
			background: #145ccd;
			color: #fff;
		}
	</style>
</head>
<body>
	
	<div class="container-fluid">
		<h2 style="padding:20px 0 40px 225px;">copy</h2>
	  <div class="row">
	     <div class="col-md-8" style="margin: 0 auto;">
			<div class="table-responsive">
			  <table class="table table-hover ">
			  	<thead>
			  		<tr>
			  			<td>序号</td>
			  			<td>平台</td>
						<td>账号</td>
						<td>操作</td>
						<td>密码</td>
						<td>操作</td>
					</tr>
			  	</thead>
			  	<tbody class="Abox">
			  	
			  	</tbody>
			    
					
			  </table>
			</div>



		  </div>
	  </div>
	</div>


	
</body>
</html>
<script src="https://cdn.bootcss.com/zui/1.8.1/lib/jquery/jquery.js"></script>
<script>
	//账号、密码数据
	let dataMsg=[{'type':"bilibili",'account':1111,'passward':16666666},
				 {'type':"腾讯视频",'account':22222,'passward':26666666},
				 {'type':"百度云",'account':33333,'passward':36666666}
				]



	/**
	 * 复制内容到粘贴板
	 * content : 需要复制的内容
	 * message : 复制完后的提示,不传则默认提示"复制成功"
	 */
	function copyToClip(clH,content, message) {
	    var aux = document.createElement("input"); 
	    aux.setAttribute("value", content); 
	    document.body.appendChild(aux); 
	    aux.select();
	    document.execCommand("copy"); 
	    document.body.removeChild(aux);
	    if (message == null) {
	        // alert("复制成功");
	     
	        clH.html("已复制")
	    } else{
	    
	    	clH.html("已复制")
	        // alert(message);
	    }
	}


	$('.Abox').on('click','.accountCopy', function(){
		let account=$(this).parents('tr').children('.account').text()
		let aHthm=$(this)
		
		copyToClip($(this),account, "已复制")
		setTimeout(function(){aHthm.html("复制")},500)


	})

	$('.Abox').on('click','.passwardCopy', function(){
		let passward=$(this).parents('tr').children('.passward').text()
		let pHthm=$(this)
		copyToClip($(this),passward, "已复制")
		setTimeout(function(){pHthm.html("复制")},500)
		

	})
	

	let strTbody=''
	let strTr=`
				<tr>
					<td>floor</td>
					<td>Type</td>
					<td class="account">accountData</td>
					<td ><div class="accountCopy hand" title="">复制</div></td>
					<td class="passward">passwardData</td>
					<td ><div class="passwardCopy hand" title="">复制</div> </td>
					
				</tr>

	`
	$('.Abox').empty()
	dataMsg.forEach(function(v,i,a){
		strTbody+=strTr.replace('floor',i+1)
						.replace('Type',a[i].type)
						.replace('accountData',a[i].account)
						.replace('passwardData',a[i].passward)

	})
	$('.Abox').append(strTbody)
	$("tr:odd").css("background-color","#cececec9");
	$("tr:even").css("background-color","#FFF");
</script>

效果展示: 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值