Skip to content Skip to sidebar Skip to footer

Cannot Read Property 'addeventlistener' Of Null Error, Not Sure Why

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.getElementById('banner'); fu

Solution 1:

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.

Solution 2:

When referencing the function normalpic, you should preceed it with an empty function:

banner.addEventListener("mouseout",function(){normalpic},false)

Post a Comment for "Cannot Read Property 'addeventlistener' Of Null Error, Not Sure Why"