I have this function which updates every 5000ms. However, when I load the page, it waits 5000ms then calls the function for the first time and then waits 5000ms to update it again and again.
I want to make it so, on page load, it instantly calls the function the first time and then waits 5000ms to call it again and again. How can I do this?
setInterval(function() {
document.getElementById("test").innerHTML = "js works";
}, 5000);
<div id="test"></div>