I am building an website, and in the home page i have 3 divs with images changing at each 10 seconds, the problem is that the website only loads the first image after 10 seconds, i am stuck in this for a while.
Javascript
function displayNextImageTop() {
z = z === imagesTop.length - 1 ? 0 : z + 1;
document.getElementById("imgtop").src = imagesTop[z];
}
function displayPreviousImageTop() {
z = z <= 0 ? imagesTop.length - 1 : z - 1;
document.getElementById("imgtop").src = imagesTop[z];
function startTimerTop() {
setInterval(displayNextImageTop, 10000);
}
var imagesTop = [],
z = 0;
imagesTop[0] = "Assets/img/TV.jpg";
imagesTop[1] = "Assets/img/Telemovel.jpg";
imagesTop[2] = "Assets/img/Processador.jpg";
for HTML I call the functions like
window.onload = function () {
startTimerSales();
startTimerNews();
startTimerTop();
};
} and then just call them in code
what can i do to the image load already with the page?