Event Listeners and Dom Manipulation

I just learned this, and am really excited by it.  It is possible to add an event listener (JavaScript) to your entire document!  Okay, I might need to get out more, but I find this pretty darn exciting.

Even better than that, though, is that you can include an event listener on the document that makes sure that all of your HTML has loaded before trying to run your JavaScript.  As an example:


document.addEventListener('DOMContentLoaded', () =>{
  //code to run only once the HTML has fully loaded
})

Comments