ask God to debug https://codepen.io/xyj/pen/KR.
everything is fine, click the entry for details. Now I want to change the direction of the arrow when the details appear. So I want to change the className, to call a different style of method, the code is as follows:
window.onload = function(){
var details = document.getElementsByClassName("detail");
var items = document.getElementsByClassName("items");
var flex = document.getElementsByClassName("flex");
var triA = document.getElementsByClassName("tri1");
var triB = document.getElementsByClassName("tri2");
j = [1,1,1,1]
for (var i = 0; i < details.length; PPi){
(function(i){
console.log(triA[i]);
details[i].addEventListener("click",function(){
if(j[i] > 0){
items[i].style.display = "block";
flex[i].innerText = "";
triA[i].className = "tri3";
triB[i].className = "tri4";
j[i] = -j[i];
}
else if (j[i] < 0){
items[i].style.display = "none";
flex[i].innerText = "";
triA[i].className = "tri1";
triB[i].className = "tri2";
j[i] = -j[i];
}
})
})(i)
}
}
two entries are fine at the beginning, and then an exception occurs
Cannot set property "className" of undefinedat HTMLDivElement