Sometimes, we want to fix document.getElementByID is not a function error with JavaScript.
In this article, we’ll look at how to fix document.getElementByID is not a function error with JavaScript.
How to fix document.getElementByID is not a function error with JavaScript?
To fix document.getElementByID is not a function error with JavaScript, we call getElementById instead of getElementByID.
For instance, we write
const element = document.getElementById("foo");
to call getElementById to get the element with ID foo.
Conclusion
To fix document.getElementByID is not a function error with JavaScript, we call getElementById instead of getElementByID.