Grow your CSS skills. Land your dream job.

jquery to slide image

  • # February 18, 2013 at 4:40 am

    this is how am making the slider to slide again and again by making the for loop condition 100 times teach me the other better and easy way thanks

    # February 18, 2013 at 5:12 am

    $(function() {
    var pictures = $(‘.commonPicClass’);
    var iPic = 0;

    function nextPic() {
    pictures.eq(iPic).fadeOut(1000);
    iPic = ++iPic % pictures.length;
    pictures.eq(iPic).fadeIn(1000);

    setTimeout(nextPic, 4000);
    }

    pictures.hide();
    pictures.eq(iPic).fadeIn(1000);

    setTimeout(nextPic, 4000);
    });

    I don’t like duplicating code, if some one has a better solution for the double `fadeIn` and `setTimeout`, let me know :P

    Demo: http://codepen.io/CrocoDillon/pen/lKebs

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".