bootstrap-switch Demo
1.引入相关的css和js文件
1.下载地址:http://www.bootcss.com/
<link href="${ctx}/plugins/bootstrap/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/plugins/bootstrap/css/bootstrap-switch.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/plugins/bootstrap/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="${ctx}/plugins/bootstrap/js/bootstrap-switch.js"></script>
<script type="text/javascript" src="${ctx}/plugins/assets/js/jquery-1.9.1.min.js"></script>
2.初始化开关
<input name="check" type="checkbox" />
window.ready=function(){
$("[name='check']").bootstrapSwitch({
onText:"启动",
offText:"停止",
onColor:"success",
offColor:"info",
size:"small",
onSwitchChange:function(event,state){
if(state==true){
alert('已打开');
}else{
alert('已关闭');
}
}
})
};