jolen
jolen

Reputation: 191

each loop not working

trying to loop through some testimonials and it doesn't loop through, just goes to the end of the comments and stops. have tried placing the each() in various locations and it still doesn't loop. Been trying to figure this out most of last night and can't seem to make it work.

my current code is:

$('.home-customer-comments').children('.customer-comment').each(function() {
    // Set first div to show
    $('.customer-comment:first').show();

    // Begin the loop, fade out, find next div, fade that div in, end the process and append back to main div.
$('.customer-comment').each(setInterval(function() {
    $('.customer-comment:first').fadeOut().hide().next('.customer-comment').fadeIn().end().appendTo('.customer-comment');
}, 1000))



});

Upvotes: 0

Views: 58

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

I think what you are looking for is

jQuery(function () {
    $('.customer-comment:first').show();
    setInterval(function () {
        $('.customer-comment:first').fadeOut().hide().next('.customer-comment').fadeIn().end().appendTo('.home-customer-comments');
    }, 1000);
});

Demo: Fiddle

Upvotes: 3

Related Questions