0

I have created a basic slider for a form, once one section of the form is complete, the user clicks 'Next' and the next section slides in....if the user wants to go back they click prev etc.

My porblem is that if a user starts out by clicking "Prev" then the form slides the wrong way and shows blank, so I need to disable the buttons when on the first and last section of the form.

My code for the slider is simple:

$(document).ready(function(){
//next/prev buttons

$("#calc_next").click(function(){
    $("#calc_container").animate({
        left: '-=800'
    });
});
$("#calc_prev").click(function(){
    $("#calc_container").animate({
        left: '+=800'
    });
});

You can see an example of my work here http://www.samskirrow.com/projects/distr/index3.html

and a jsfiddle here http://jsfiddle.net/5udRZ/

4

1 回答 1

0

像这样在里面设置一个if语句$("#calc_prev").click(function(){

$("#calc_prev").click(function(){
    if($("#calc_container").position().left >= 0 ) 
        {return;}
    else { 
        $("#calc_container").animate({
            left: '+=800'
        });
    }
});
于 2013-09-10T10:37:36.587 回答