浙江师范大学-网络继续教育学院-视频连播!
< Feedback on 浙江师范大学-网络继续教育学院-视频连播
终于搞定了,原来是document.querySelector(".px-course-list > div:nth-child(1)还没有载入的问题,添加setInterval来循环判断是否载入成功即可正常运行 let wait = setInterval(()=>{ console.log("等待载入") if(document.querySelector(".px-course-list > div:nth-child(1)")){ console.log("载入成功") clearInterval(wait) let course = document.querySelector(".px-course-list > div:nth-child(1)"); //let over = course.getElementsByClassName("progress-bar")[0]; //获取课程标签 kecheng(course); } },1000)
Sign in to post a reply.
终于搞定了,原来是document.querySelector(".px-course-list > div:nth-child(1)还没有载入的问题,添加setInterval来循环判断是否载入成功即可正常运行
let wait = setInterval(()=>{
console.log("等待载入")
if(document.querySelector(".px-course-list > div:nth-child(1)")){
console.log("载入成功")
clearInterval(wait)
let course = document.querySelector(".px-course-list > div:nth-child(1)");
//let over = course.getElementsByClassName("progress-bar")[0];
//获取课程标签
kecheng(course);
}
},1000)