I\'m learning jQuery and was following a tutorial, a very strange error has perplexed me. Here\'s my html :
In my case, I was using it on an element
instead of document
, and according to MDN:
Unlike some other element-lookup methods such as Document.querySelector() and Document.querySelectorAll(), getElementById() is only available as a method of the global document object, and not available as a method on all element objects in the DOM. Because ID values must be unique throughout the entire document, there is no need for "local" versions of the function.