Unable to set property 'checked' of undefined or null reference報(bào)錯(cuò)原因
for(i?=?0?;?i?<=hobby.length?;?i++){ ??????????????hobby[i].checked?=?true?; ????????????}
這個(gè)程序在瀏覽器里運(yùn)行會(huì)報(bào)錯(cuò)
SCRIPT5007: Unable to set property 'checked' of undefined or null reference
但是程序?qū)崿F(xiàn)正常
這個(gè)報(bào)錯(cuò)是什么原因呢?
2015-11-28
從報(bào)錯(cuò)信息上來(lái)看
循環(huán)內(nèi)的
hobby[i] 是一個(gè)null或undefined,你并不能在null或undefined身上綁定屬性。。
例如下面的就會(huì)報(bào)錯(cuò):