javascript wait for document load 1

javascript wait for document load

document.addEventListener("DOMContentLoaded", function(event) { 
  //do work
});

Here is what the above code is Doing:
1. We’re using the document object to access the DOM.
2. We’re using the addEventListener() method to listen for a “DOMContentLoaded” event.
3. When the event is detected, a callback function is executed to do some work.

Similar Posts