+ 4
How to make my JavaScript excute only after the html document is completely loaded?
I wrote a code in the sololearn web playground but my javascript show a 'cant execute appendChild property of null' and i'm sure it's becsuse the js file is liaded before the element i want to change.
4 ответов
+ 5
Elon Yemp
You can write JavaScript code inside window.onload function or inside this
$(document).ready(function () {
//js.code
}
window.onload = function () {
//js code
};
document.addEventListener("DOMContentLoaded", function (event) {
//js code
});
window.addEventListener('load', function () {
js code
});
You can use any one from the above function.
+ 3
It worked ! Thanks !
+ 2
Ok im gonna try it
+ 2
AJ #Learn With Me 👨💻 I think you have to mention that the 1st example assumes jquery