时间:2021-10-17 09:12:30 | 栏目:JavaScript代码 | 点击:次
修改开关的值
.mui-switch:before{ font-size: 13px; position: absolute; top: 3px; right: 11px; content: attr(data-off); text-transform: uppercase; color: #999; } .mui-switch.mui-active:before{ right: auto; left: 15px; content: attr(data-on); color: #fff; } <div class="mui-content"> <ul class="mui-table-view"> <li class="mui-table-view-cell"> <span>报警消息设置</span> <div class="mui-switch mui-active" id="mySwitch" data-off="关" data-on = "开"> <div class="mui-switch-handle"></div> </div> </li> </ul> </div>
控制开关状态:
document.getElementById("mySwitch").addEventListener("toggle",function(event){ if(event.detail.isActive){ var btnArray = ['取消', '确认']; mui.confirm('关闭报警推送消息后,系统将不再推送报警消息?', '警告!', btnArray, function(e) { if(e.index==1){ console.log("你关闭了报警推送"); }else{ mui("#mySwitch").switch().toggle(); } },'div') }else{ } })