I would like to design a page on which the back ground image changes in a round-robin fashion, indefinitely. Now I have something that works but only if there's no other <div>
s on that page as it loops through all the div
s. Now I want to add content in other div
s so I need to edit that jQuery
somehow to only loop through the div
s with "backgnd" in their class name. How do I do this? My example link: http://jsfiddle.net/bbqunfhu/26/
function to edit:
function fadeDivs() {
var visibleDiv = $('.bckgnd:visible:first'); //find first visible div
visibleDiv.fadeOut(400, function () { //fade out first visible div
var allDivs = visibleDiv.parent().children(); //all divs to fade out / in
var nextDivIndex = (allDivs.index(visibleDiv) + 1) % allDivs.length; //index of next div that comes after visible div
var nextdiv = allDivs.eq(nextDivIndex); //find the next visible div
nextdiv.fadeIn(400); //fade it in
});
};