Cannot read property 'addEventListener' of null Error, not sure why

前端 未结 2 432
误落风尘
误落风尘 2021-01-27 05:16

Whenever I hover over the image it does not enlarge and gives an error.

HTML and Javascript code(these are two separate files):

var banner = document.ge         


        
2条回答
  •  情话喂你
    2021-01-27 06:01

    Your javascript code is in your first section. So it has rendered before banner element and cannot find the element id = banner because it has not rendered yet. Try to locate the code before the html code.

提交回复
热议问题