<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>jQuery移动端单选按钮美化特效 - 更多源码【www.96flw.com】</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- core css -->
<link rel="stylesheet" href="css/lc_switch.css">
<style type="text/css" media="screen">
body{margin: 0; padding: 0; background-color: #f1f1f1;}
.inner-input{background-color: #fff;}
.inner-input{position: relative; box-sizing: border-box; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; padding: 16px 16px; font-size: 16px; border-bottom: 1px solid #f2f2f2;}
.inner-input label{height: 18px; width: 4.5em; -ms-flex-negative: 0; flex-shrink: 0; -webkit-box-flex: 0; -ms-flex-positive: 0; flex-grow: 0; margin-right: 16px; color: #333;}
.to_chose{position: absolute; right: 15px; top: 10px; }
.btn{position: fixed; width: 100%; height: auto; bottom: 0; border-top: 1px solid #f2f2f2; padding: 8px 16px; box-sizing: border-box; background-color: #fff;}
button{width: 100%; line-height: 45px; font-size: 16px; border: none; border-radius: 3px; cursor: pointer; }
button{background-color: #EC8336; color: #FFF;}
.btn-groups button{background-color: #EC8336; margin: 0 16px; }
.btn-groups button:hover{ background-color: #E5792A; }
.btn-groups button.reset{background-color: #9E9E9E;}
.btn-groups button.reset:hover{background-color: #BDBDBD;}
</style>
</head>
<body>
<div class="inner-input">
<label class="fixed-w" style="width: 8em;">10.销售部</label>
<div class="to_chose">
<input type="checkbox" class="lcs_check" name="dept" value="10" autocomplete="off" />
</div>
</div>
<div class="inner-input">
<label class="fixed-w" style="width: 8em;">20.市场部</label>
<div class="to_chose">
<input type="checkbox" class="lcs_check" name="dept" value="20" autocomplete="off" />
</div>
</div>
<div class="inner-input">
<label class="fixed-w" style="width: 8em;">30.财务部</label>
<div class="to_chose">
<input type="checkbox" class="lcs_check" name="dept" value="30" checked autocomplete="off" />
</div>
</div>
<div class="inner-input">
<label class="fixed-w" style="width: 8em;">40.设计部</label>
<div class="to_chose">
<input type="checkbox" class="lcs_check" name="dept" value="40" autocomplete="off" />
</div>
</div>
<div class="inner-input">
<label class="fixed-w" style="width: 8em;">50.研发部</label>
<div class="to_chose">
<input type="checkbox" class="lcs_check" name="dept" value="50" checked autocomplete="off" />
</div>
</div>
<div class="inner-input btn-groups">
<button type="button" onClick="checkfun(40, 1)" class="do">选中设计部</button>
<button type="button" onClick="checkfun(30, 0)" class="do">取消财务部</button>
<button type="button" onClick="resetfun()" class="reset" >重置</button>
</div>
<div class="btn">
<button type="button" class="save">保存信息</button>
</div>
<!-- 依赖jquery -->
<script src="js/jquery.min.js"></script>
<!-- core library -->
<script src="js/lc_switch.min.js"></script>
<script type="text/javascript">
$('.lcs_check').lc_switch();
</script>
<script type="text/javascript">
var checkfun = function (val, checked) {
var checkNode = $("[name=dept][value="+val+"]")
checked ? checkNode.lcs_on() : checkNode.lcs_off();
}
var resetfun = function () {
window.location.reload();
}
$('.save').click(function(){
// 获取选中的值
var checkids = [];
$('[name=dept]:checked').each(function(item){
checkids.push( $(this).val() )
})
alert( "选中的部门:" + checkids.join(',') )
})
</script>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
<p>适用浏览器:360、FireFox、Chrome、Opera、傲游、搜狗、世界之窗. 不支持Safari、IE8及以下浏览器。</p>
<p>更多源码<a href="http://www.96flw.com" target="_blank">www.96flw.com</a></p>
</div>
</body>
</html>