报错信息('style' of undefined at HTMLLIElement.lis)

作业3.html?_ijt=5h8h0o4smtc0onigbr9fumlgfd:24 Uncaught TypeError: Cannot read property ‘style’ of undefined
at HTMLLIElement.lis..onclick (作业3.html?_ijt=5h8h0o4smtc0onigbr9fumlgfd:24)
lis..onclick @ 作业3.html?_ijt=5h8h0o4smtc0onigbr9fumlgfd:24
报错信息('style' of undefined at HTMLLIElement.lis)
这是代码,报错信息在lis[i].style.backgroundColor=“red”;
报错意思:style没有值

改正方法:
报错信息('style' of undefined at HTMLLIElement.lis)
lis[i]改为this即可代替事件绑定
法二:经过讨论,把var变量换成let
命名变量时,采用let,在es6语法中,let所在代码块会形成一个封闭空间[作用域],不会受到外部赋值的影响
在for循环中,循环条件[语句]会形成一个父作用域,循环体内部则是一个子作用域