的jQuery
for (i = 0; i <= globalStore.data.length;i++ ) {
/ 混乱开始 /
$(".morning").each(function() {
//getting id for each div of class 'morning'
var id = $(this).attr("id");
/ 但所有这些css更改都是针对div进行的,并且上课时间为&#39;没有匹配id /
$(this).children("span").css("background-color","#ff0");
$(this).children("span").each(function() {
if(globalStore.data[i].morning.indexOf($(this).attr("class")) > -1) {
$(this).css("color","#26F525");
}
});
});
/ 混淆结束 /
<div class='morning' id='mor_"+globalStore.data[i].UUID+"'>Morning: <span class='Mon'>M </span><span class='Tue'>T </span><span class='Wed'>W </span><span class='Thrs'>T </span><span class='Fri'>F </span><span class='Sat'>S </span><span class='Sun'>S</span></div>
}
我希望能够做类似的事情
$(".morning").each(function() {
var ID = $(this).attr("id");
/ *检查并更改每个ID * /
$(this ID).children("span").each(function() {
if(globalStore.data[i].morning.indexOf($(this).attr("class")) > -1) {
$(this).css("color","#26F525");
}
});