MUI+H5+ 开发 爬坑

一、页面跳转

  1. 用href跳转
 忘记密码
 //解决 所有a标签 导航不能跳转页面
mui('body').on('tap','a',function(){document.location.href=this.href;});

解决方法来自 https://blog.csdn.net/tanmuxue/article/details/52682337

  1. 用事件跳转
mui('.mui-content-padded').on('tap','#login' ,function(event) {
		mui.openWindow({
				  	 url:'index.html',
  					 id:'index.html'
		});
})

二、获取文本框、单选按钮的值

//单选按钮
var ele = document.getElementsByName("loginType");
			for (var i = 0; i < ele.length; i++) {
				if(ele[i].checked == true){
					mui.alert(ele[i].value + ": " + ele[i].checked)
				}
			};
//文本框
var c=mui("#username")[0].value;
//循环判断是否未空
			mui(".mui-input-group input").each(function () {
				var zhang=this.value;
				console.log(zhang);
			  //若当前input为空,则alert提醒
			  if(!this.value){
			    var label = this.previousElementSibling;
			    console.log(label);
			    mui.alert(label.innerText+"不允许为空");
			    check = false;
			    return false;
			  }
			});

你可能感兴趣的:(基础)