Grow your CSS skills. Land your dream job.

problem in Jquery horizontal slider

  • # April 30, 2012 at 2:15 am

    Guys,
    i have made a custom Jquery image slider with ‘next’ and ‘prev’ buttons but some how it is not working properly. The prob is it goes on sliding when the images over.

    http://jsfiddle.net/matthew_b/suzgM/

    # April 30, 2012 at 10:35 am

    Try this (demo):

    $(function() {
    var $current = $("#container li"),
    len = $current.length-1,
    current = 0;

    $("#next, #prev").click( function(){
    current += (this.id === 'next') ? 1 : -1;
    if (current < 0) {
    current = 0;
    return;
    }
    if (current > len) {
    current = len;
    return;
    }
    $current.animate({
    left: -790*current,
    top: 0
    });
    });
    });​

    # June 25, 2012 at 7:33 am

    perfect :) Thanks a lot @Mottie

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

You must be logged in to reply to this topic.

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