在百度前端学院中斌斌学院任务八,用二叉树依次显示,经过几轮后就找不到nodevalue属性
function preOrder(node) {
if (!(node == null)) {
lists.push(node);
var allChild = node.children;
for (let i = 0; i < allChild.length; i++) {
preOrder(allChild[i]);
}
}
}
function changeColor() {
var i = 0;
// lists[i].style.backgroundColor = "red";
timer = setInterval(function(){
if (i<lists.length) {
if (i>0) {
lists[i-1].style.backgroundColor = "#fff";
}
lists[i].style.backgroundColor = "grey";
if (lists[i].firstChild.nodeValue == content.value) {
lists[i].style.border = "1px bold red";
bool = true;
}
}else{
clearInterval(timer);
lists[i-1].style.backgroundColor = "#fff";
}
i++;
},500)
}
function clear() {
clearInterval(timer);
lists = [];
}
小伙看你根骨奇佳,潜力无限,来学PHP伐。