let obtn = document.getElementsByTagName("li");
let oElec = document.getElementsByClassName("elec");
let i = 0;
for (i = 0; i < obtn.length; i++) {
obtn[i].index = i;//记录索引值
obtn[i].onclick = function () {
for (let j = 0; j < obtn.length; j++) {
obtn[j].className = "";
oElec[j].style.display = 'none';
}
this.className = "active";
oElec[this.index].style.display = "block";
};
}
118.php:269 Uncaught TypeError: Cannot read properties of undefined (reading 'style')
at obtn..onclick (118.php:269:30)