Skip to content
Advertisement

How to tell JavaScript to execute a function after an element has been loaded?

How to tell JavaScript to execute a function after an element has been loaded w/out any external library?
Normally I have to bring the <script> tag after the element itself to work with DOM calls.

Advertisement

Answer

Well you can utilize the document.onload and window.onload methods
For example:

window.onload = function(){
   //do some stuff 
}
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement