The this.contentli[i].style attribute cannot be accessed because the this.contentli[i] attribute is undefined, and the .style of an undefined object cannot of course be accessed.
First check the value of this.contentli[i] when you run it, and then combine the above code that defines this.contentli[i] to troubleshoot why this.contentli[i] is not defined.
this.contentli[i] is undefined, and it should be that the value of i exceeds this.contentli.length - 1, which is the maximum subscript of this.contentli.
The error is very obvious. There is no
style
attributein
this.contentli[i]If you are not sure, just print the line above
console.log(this.contentli[i]);
Try console.log(this.contentli[i]). If the returned object is not a DOM object, then the code is wrong. .
The
this.contentli[i].style
attribute cannot be accessed because thethis.contentli[i]
attribute is undefined, and the.style
of an undefined object cannot of course be accessed.First check the value of
this.contentli[i]
when you run it, and then combine the above code that definesthis.contentli[i]
to troubleshoot whythis.contentli[i]
is not defined.this.contentli[i]
isundefined
, and it should be that the value ofi
exceedsthis.contentli.length - 1
, which is the maximum subscript ofthis.contentli
.