Can anyone tell me what I'm doing wrong in my code below? The timeout isn't working - my page is just showing in a split second. Thanks in advance
<body onload=myFunction()>
<div id="loading"></div>
</body>
var preloader = document.getElementById("loading");
window.addEventListener('load', function() {
preloader.style.display = 'none';
})
function myFunction() {
setTimeout(function() {
preloader.style.display = 'none';
}, 5000)
};
If you remove the window.addEventListener('load', ...);, your content will show for 5 seconds.