发表于: 2020-07-28 22:04:12
1 1122
今天完成的事情:
学习了js的知识
//获取记录值
var span0 = document.querySelectorAll('#span0');
var span1 = document.querySelectorAll('#span1');
//遍历当天之前的天数按钮变色
for(i = 0;i< first-1;i++){
li0s[i].style.background = '#6f949d';
li1s[i].style.background = '#6f949d';
li2s[i].style.background = '#6f949d';
li3s[i].style.background = '#6f949d';
ul[i].style.display = 'none';
span0[i].style.opacity = '1';//将玩家死亡记录显示
span1[i].style.opacity = '1';
}
//判定点击后显示
if(!li0s[first-1].style.background == ''){
span0[first-1].style.opacity = '1';
}
//将数组取出并转化成对象
var kipeArrName = JSON.parse(localStorage.getItem("kipeArr"));
var tipsarr = JSON.parse(localStorage.getItem('tipsarr'));
//创建玩家号码、身份数组
var feel = [];//偶数数组
var statusarr = [];
var feel1 = [];//奇数数组
var statusarr1 = [];
for (var i = 0;i< tipsarr.length;i++){
if(i%2 == 0){//遍历出偶数下标并返回数组
feel.push(tipsarr[i]);
var ss = tipsarr[i];
statusarr.push(kipeArrName[ss]);
}else{//遍历奇数下标返回数组
feel1.push(tipsarr[i]);
var ts = tipsarr[i];
statusarr1.push(kipeArrName[ts]);
}
}
//遍历被杀死和被投死的信息
for (var i = 0;i<feel.length;i++){
span0[i].innerHTML = `${feel[i]+1}号被杀死,真实身份是${statusarr[i]}`;
span1[i].innerHTML = `${feel1[i]+1}号被投死,真实身份是${statusarr1[i]}`
}
//获取按钮属性
var btn = document.querySelectorAll("button");
btn[1].onclick = function(){
location.href = "2-3.html";
}
明天计划的事情:
继续完成任务
评论