Reputation: 141
JQuery noob at it again.
Here is an example of what I am trying to achieve.
$(function(){
var fourDivs = $('#window > div');
var doSlide = function (){
if (fourDivs)
fourDivs
.delay(1000)
.animate({marginLeft: 50})
.delay(1000)
.animate({marginLeft: 250})
.delay(500)
.fadeOut(200)
.animate({marginLeft: -200})
.fadeIn(500)
};
doSlide();
setInterval(doSlide, 2000);
});
I assume this is an amusing, however poor attempt.
For all the experts out there, do I have the right idea? What would you guys recommend?
How would I get an animated loop as such to continue to cycle through a class of divs?
Thanks in advance.
Upvotes: 3
Views: 213
Reputation: 394
I suggest you try the jquery api queue,but I don't know this details.
Upvotes: 0
Reputation: 405
Using jQuery's .each()
function:
function loop () {
$('#window > div').each(function (index, myDiv) {
if (myDiv) {
myDiv
.delay(1000)
.animate({marginLeft: 50})
.delay(1000)
.animate({marginLeft: 250})
.delay(500)
.fadeOut(200)
.animate({marginLeft: -200})
.fadeIn(500);
}
});
}
setTimeout(loop, 1000);
Edit: didnt read your question properly
Upvotes: 2