Thursday, May 9, 2019

html - Javascript - getElementById() returns null even though the element exists




I'm trying to get the element with getElementById(), but it returns null.



This is the error I get on mozilla firefox debugger




"TypeError: document.getElementById(...) is null".




What is wrong in the code?








Stack




Frame One


Frame Three


Frame Two









Answer



top appears to be a reserved variable -- it resolves to window.top in your function. Try naming top something else like _top and you shouldn't get any errors.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...