Тут я описал как получается подобная ситуаця: Ошибка Uncaught TypeError: Cannot set property 'innerHTML' of null.