草稿for套for

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>服务设置</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.min.css">
<link rel="stylesheet" href="css/grandeHealth.css">
<style>
.mui-table-view-cell{padding: 15px;}
.mui-table-view-cell:after {left: 0;}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
</header>
<div class="mui-content">
<ul class="mui-table-view">
<li class="mui-table-view-cell">
图文咨询服务
<div name="1" id="twCs" class="mui-switch mui-active mui-switch-mini">
<div class="mui-switch-handle"></div>
</div>
</li>

<li class="mui-table-view-cell">
语音咨询服务
<div name="1" id="voiceCs" class="mui-switch mui-active mui-switch-mini">
<div class="mui-switch-handle"></div>
</div>
</li>
<li class="mui-table-view-cell">
视频咨询服务
<div name="1" id="videoCs" class="mui-switch mui-active mui-switch-mini">
<div class="mui-switch-handle"></div>
</div>
</li>
</ul>
</div>
</body>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/grandeHealth.js"></script>
<script>
mui.init({
swipeBack:true //启用右滑关闭功能
});

var HEART_APP_USRGUID = '59206BEE10ABE361E050007F0100077D';
var arry = {};
var webUrl = HEART_WEBBASE + "Docpl/Select?&pageSize=10&crtusr="+HEART_APP_USRGUID;
function jiaohu() {
try {
$.ajax({
url: webUrl,
type: "GET",
async: false,
dataType: "json",
success: function(data) {
try {


} catch(e) {

mui.toast('获取数据失败');
}
},
error: function(xhr, textStatus, error) {
if(textStatus == "error")
mui.toast('请检查网络连接');
}

});

} catch(e) {

mui.toast("请检查网络连接");

}

};

// jiaohu();


/*
* ajax请求封装
*/
function _ajax(url,data,callback){
try {
$.ajax({
url:url,
type:"POST",
data:data,
dataType:'json',
success: function(data) {
try {

if(data.code == '000'){
mui.toast('修改成功')
}else{
mui.toast('修改失败');
}

} catch(e) {

mui.toast('获取数据失败');
}
},
error: function(xhr, textStatus, error) {
if(textStatus == "error")
mui.toast('请检查网络连接');
}

});

} catch(e) {

mui.toast("请检查网络连接");

}
}


// mui("body").on("tap", ".mui-table-view-cell .mui-switch", function() {
//
// console.log($(this).parent('li').index())
//// showpage('set.html?usrguid='+HEART_APP_USRGUID);
//// console.log($(this).attr('name'))
// })

// document.getElementsByClassName('mui-switch')[0].onclick=function(){
// alert(999)
// };



var aLi = document.getElementsByTagName("li");


for(let i = 0;i< aLi.length; i++){



var alichirend = aLi[i].childNodes;
// console.log(alichirend)



for(var j = 0 ; j < alichirend.length; j ++){


if(typeof(alichirend[j].id)!="undefined"){

console.log(alichirend[j].id)

// console.log("i="+i,"j="+j)
// console.log(typeof(alichirend[j].id)=="undefined")
}

}
// console.log(typeof("ssss"))

// console.log(alichirend)
// if(alichirend == 'twCs'){
// alert(999999)
// }


}


// for(var i = 0 ; i < )




// document.getElementsByClassName('mui-table-view-cell');


// document.getElementById("twCs").addEventListener('toggle',function (e) {
// var isActive = e.detail.isActive;
// if (isActive) {
//
// this.setAttribute('name','1')
// imaget = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
// _ajax(webUrl);
//
// } else {
// this.setAttribute('name','0')
// imaget = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
// _ajax(webUrl);
// }
// });






//&id=c191698b4e6b47ae876a027e46c89e14



var imaget = $('.mui-table-view li:nth-child(1)').children('div').attr('name');
var voicet = $('.mui-table-view li:nth-child(2)').children('div').attr('name');
var videot = $('.mui-table-view li:nth-child(3)').children('div').attr('name');
var allUrl = HEART_WEBBASE+"docApp/insertHealthServiceConfig?&USRGUID="+HEART_APP_USRGUID;

/*
* 图文咨询服务
*/
// document.getElementById("twCs").addEventListener('toggle',function (e) {
// var isActive = e.detail.isActive;
// if (isActive) {
//
// this.setAttribute('name','1')
// imaget = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
// _ajax(webUrl);
//
// } else {
// this.setAttribute('name','0')
// imaget = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
// _ajax(webUrl);
// }
// });

/*
* 语音咨询服务
*/
// document.getElementById("voiceCs").addEventListener('toggle',function (e) {
// var isActive = e.detail.isActive;
// if (isActive) {
//
// this.setAttribute('name','1')
// voicet = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
//
// _ajax(webUrl);
//
// } else {
// this.setAttribute('name','0')
// voicet = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
//
// _ajax(webUrl);
// }
// });

/*
* 视频咨询服务
*/
// document.getElementById("videoCs").addEventListener('toggle',function (e) {
// var isActive = e.detail.isActive;
// if (isActive) {
//
// this.setAttribute('name','1')
// videot = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
//
// _ajax(webUrl);
// } else {
// this.setAttribute('name','0')
// videot = this.getAttribute('name');
// var webUrl = allUrl+"&imageservice="+imaget+"&voiceservice="+voicet+"&videoservice="+videot;
//
// _ajax(webUrl);
// }
// });
</script>
</html>

゛Toly★小饼干ゞ
原文地址:https://www.cnblogs.com/rockyan/p/7737345.html