J'écris ce script pour faire pivoter une image d'arrière-plan toutes les 3 secondes, mais cela ne fonctionne pas du tout et je suis perplexe quant à savoir pourquoi.jquery background image Le script de rotation ne fonctionne pas
$(document).ready(function() {
var inc = 0;
var bgImages = new Array();
bgImages.push("Images/backgroundDog-small.jpg");
bgImages.push("Images/backgroundDog1-small.jpg");
bgImages.push("Images/backgroundDog2-small.jpg");
bgImages.push("Images/backgroundDog3-small.jpg");
setInterval(change, 3000);
function change() {
//if we're not at the end of the array
if (inc < (bgImages.length)) {
var image = bgImages[inc];
$('body').css('backgroundImage', image);
console.log(image);
inc++;
//reset the counter inc and go through the array again
} else {
inc = 0;
}
}
});
Que se passe-t-il? Les chemins de l'image sont-ils corrects? – SLaks
L'arrière-plan est blanc. Oui, les chemins de l'image sont corrects. – Catfish