Traditionally, to call a JavaScript function once the page has loaded, you\'d add an onload
attribute to the body containing a bit of JavaScript (usually only c
Another way to do this is by using event listeners, here how you use them:
document.addEventListener("DOMContentLoaded", function() {
you_function(...);
});
Explanation:
DOMContentLoaded It means when the DOM Objects of the document are fully loaded and seen by JavaScript, also this could have been "click", "focus"...
function() Anonymous function, will be invoked when the event occurs.