checkbox运用

做一个简单,复选框事件。

<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css"/>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/general.css"/>
		<style type="text/css">
			
			.mui-content{
				background-color: #F2F2F2;
			}
			
			.content{
				width: 100%;
				background-color: #F2F2F2;
				padding: 10px;
			}
			.search{
				display: flex;
				justify-content: center;
				align-content: center;
				padding: 10px;
				background-color: white;
			}
			.stext{
				width: 25%;
				text-align: center;
				display: flex;
				justify-content: center;
				align-items: center;
				border-right:1px solid #C7C7CC;
			}
			.simg{
				width: 30px;
				height: 30px;
			}
			.simg>img{
				width: 100%;
				height: 100%;
			}
			.ssdiv{
				width: 75%;
			}
			.ssinp{
				width: 100%;
				height: 100%;
				border: 0;
				padding-left: 10px;
			}
			::-webkit-input-placeholder{
				font-size: 0.8em;
				color: #999999;
			} 
			.sjx{
				margin: auto;
				width: 0;
				height: 0;
			    border:10px solid transparent;
				border-top: 10px solid #000000;
				position: relative;
				top: 20%;
			}
			.cancell{
				width: 100%;
				padding: 10px;
			}
			.checklist{
				background-color: white !important;
				border-radius: 0.5em;
				margin: 5px auto;
			}
			.toptext{
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 2px;
				
			}
			.fs1{
				font-size: 1em;
			}
			.fs08{
				font-size: 0.8em;
			}
			.fs07{
				font-size: 0.7em;
			}
			
			
			
			
.footdiv{
				position: fixed;
				bottom: 0;
				width: 100%;
				height: 3.4em;
				background-color: white;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			.gd{
				height: 3.4em;
				width:100% ;
			}
			.fleft{
				width: 70%;	
				display: flex;
				padding-left: 1em;
				justify-content: flex-start;
				align-items: center;
			}
			.fright{
				height: 3.4em;
				background-color: #007AFF;
				text-align: center;
				width: 30%;
				line-height: 3.4em;
				color: white;
			}
			.fimg{
				width: 2.5em;
				height: 2.5em;
			}
			.fimg>img{
				width: 100%;
				height: 100%;
			}
			
		</style>
	</head>

	<body>
		
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">挂单列表</h1>
		</header>
		<div class="mui-content">
		    <div class="content">
		    	<div class="search">
		    		<div class="stext">
		    			单据号
		    			<div class="sjx">
		    			</div>
		    			
		    		</div>
		    		<div class="ssdiv">
		    			<input class="ssinp" type="" name="" id="" value=""  placeholder="请输入单据号/手机号/卡号/姓名/车牌号"/>
		    		</div>
		    		<div class="simg">
		    			<img src="../images/60x60.gif"/>
		    		</div>
		    	</div>
		    </div>
		    
		    <div class="cancell">
		    	<div class="" id="canlist">
		    		<!--
                    	作者:592176224@qq.com
                    	时间:2018-12-28
                    	描述:
                    
		    		<div class="mui-input-row mui-checkbox checklist">
		    		    <label>
		    		    	<div class="toptext fs1">
		    		    		<span id="">
		    		    			XF565651651651656
		    		    		</span>
		    		    		<span style="color: orange;">
		    		    			¥100.00
		    		    		</span>
		    		    	</div>
		    		    	<div class="toptext fs07">
		    		    		<span id="">
		    		    			某某(12025541551)
		    		    		</span>
		    		    	</div>
		    		    	<div class="toptext fs08">
		    		    		<span id="">
		    		    			2018-12-15 12:18:00
		    		    		</span>
		    		    		<span>
		    		    			已退单
		    		    		</span>
		    		    		<span id="">
		    		    			未结  <span style="color: orange;">
		    		    				点击结账
		    		    			</span>
		    		    		</span>
		    		    	</div>
		    		    	
		    		    </label>
		    		    <input name="Checkbox" type="checkbox" checked>
		    		</div>
		    		-->
		    	</div>
		    	
		    </div>
		    
		    
		    <div class="footdiv">
		    	<div class="fleft">
		    		<div class="mui-input-row mui-checkbox ">
		    		    <label>全选</label>
		    		    <input name="Checkbox" id="checkall" type="checkbox">
		    		</div>
		    	</div>
		    	<div class="fright">
		    		删除
		    	</div>
		    </div>
		    
		</div>
		<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript">
			window.onload = function(){
				
				getcamlist(3)
				document.getElementById('checkall').addEventListener('change',function() {
		            var listBox = mui('.listcheckbox');
		            if (this.checked) {
		                listBox.each(function() {
		                    this.checked = true;
		                })
		            } else {
		                listBox.each(function() {
		                    this.checked = false;
		                })
		            }
		        })
			}
			
			function setcheckbox(e){
				if(!e.checked){
					//$('#checkall').removeAttribute('checked');
					document.getElementById('checkall').checked = false;
				}
			}
			
			function getcamlist(id){
				let canlist = document.getElementById("canlist");
				let str = '<div class="mui-input-row mui-checkbox checklist">\
		    		    <label><div class="toptext fs1"><span id="">\
		    		    XF565651651651656\
		    		    </span><span style="color: orange;">\
		    		    ¥100.00\
		    		    </span></div><div class="toptext fs07"><span id="">\
		    		    某某(12025541551)\
		    		    </span></div><div class="toptext fs08"><span id="">\
		    		    2018-12-15 12:18:00\
		    		    </span><span>\
		    		    已退单\
		    		    </span><span id="">\
		    		    未结  <span style="color: orange;">点击结账\
		    		    </span></span></div></label>\
		    		    <input name="Checkbox" class="listcheckbox" onchange="setcheckbox(this)" type="checkbox"></div>';
				
				for (let i = 0; i <id; i ++) {
					canlist.innerHTML += str;
				}
				
			}
		</script>
	</body>

</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值