Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript problem in Jquery horizontal slider

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37846
    matthewb
    Member

    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/

    #102005
    Mottie
    Member

    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
    });
    });
    });‚Äč

    #104841
    matthewb
    Member

    perfect :) Thanks a lot @Mottie

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.