search

Home  >  Q&A  >  body text

javascript - Why is an error reported here?

How to modify

黄舟黄舟2809 days ago655

reply all(4)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-07-05 10:38:25

    The error is very obvious. There is no style attribute in this.contentli[i]

    If you are not sure, just print the line aboveconsole.log(this.contentli[i]);

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-07-05 10:38:25

    Try console.log(this.contentli[i]). If the returned object is not a DOM object, then the code is wrong. .

    reply
    0
  • 欧阳克

    欧阳克2017-07-05 10:38:25

    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.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-07-05 10:38:25

    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.

    reply
    0
  • Cancelreply