带有勾选按钮的多选列表
<span class="cbox" onclick="this.className=/checked/ig.test(this.className)?this.className.replace('checked',''):(this.className+' checked')"></span>
当点击时替换className达到切换的母的。
具体代码如下:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
.contain{
width: 280px;
border: 1px solid lightgray;
border-radius: 5px;
}
.contain .order_item{
width: 100%;
min-height: 85px;
display:box;
display:-moz-box;
display: -webkit-box;
}
.order_item .cbox{
display:block;
width:16px;
height:16px;
border:1px solid lightgray;
background:#fff;
border-radius: 50%;
margin-left: 5px;
margin-top: 12%;
}
.order_item .cbox.checked{
background:rgb(106,202,37);
}
.order_item .cbox.checked:after{
content:""
}
.order_item .order_info{
width: calc(100% - 32px);
margin-left: 5px;
margin-top: 5px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<div class="contain">
<div class="order_item">
<span class="cbox" onclick="this.className=/checked/ig.test(this.className)?this.className.replace('checked',''):(this.className+' checked')"></span>
<div class="order_info">
</div>
</div>
<div class="order_item">
<span class="cbox" onclick="this.className=/checked/ig.test(this.className)?this.className.replace('checked',''):(this.className+' checked')"></span>
<div class="order_info">
</div>
</div>
<div class="order_item">
<span class="cbox" onclick="this.className=/checked/ig.test(this.className)?this.className.replace('checked',''):(this.className+' checked')"></span>
<div class="order_info">
</div>
</div>
<div class="order_item">
<span class="cbox" onclick="this.className=/checked/ig.test(this.className)?this.className.replace('checked',''):(this.className+' checked')"></span>
<div class="order_info">
</div>
</div>
<div class="order_item">
<span class="cbox" onclick="this.className=/checked/ig.test(this.className)?this.className.replace('checked',''):(this.className+' checked')"></span>
<div class="order_info">
</div>
</div>
</div>
</body>
</html>
效果图: