I tried to call a function, when all DOM elements in the page are loaded, like this:
document.addEventListener('DOMContentReady', function() {alert("good")});
It's an HTML file with an empty body and empty head except this JavaScript and nothing happens even if the browser finished loading. What could be wrong here? And are there other ways to do this?
There's no DOMContentReady
event.
You want DOMContentLoaded
.
document.addEventListener('DOMContentLoaded', function() {alert("good")});
DEMO: http://jsfiddle.net/JQhjj/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With