单击按钮时jQuery事件加倍

时间:2012-06-10 21:04:33

标签: jquery events scroll

我整天都在努力解决这个问题。

我有一个jQuery按钮,当点击时淡入一个字段。该字段是一个可滚动的表,向左滚动三次,向右滚动三次。

滚动长度与其容器大小有关(溢出:隐藏)但是我遇到的问题是一切正常,除非我再次单击原始按钮。每次单击此按钮,它都会使每个方向的滚动距离值加倍。这几乎就像按钮加倍了事件。

(文档)$。就绪(函数(){

$('.pcode_btn').click(function(event){
    var pcode=$('.pcode').val();
    var pcode=$('.pcode2').val();
    if(pcode==""){
        //nothing entered
        alert("Please enter your clients postcode");
        return;
    }

    //show calender

    $('.calender_holder').fadeIn(500);
    $('.instr').text("Select a suitable time when your client is available for one of our agents to visit by selecting an available time-slot below.");
    //slide calender

    $('.next').click(function(event){
    if($('.date_holder').css('left') != '-1743px') {
        $(this).prop('disabled', true)    
        $('.date_holder').animate({left:'-=581px'}, 500, function() {
            $('.next').prop('disabled', false)    
            });
        }

        return false;
    });

    $('.prev').click(function(event){
    if($('.date_holder').css('left') != '0px') {
        $(this).prop('disabled', true)   
        $('.date_holder').animate({left:'+=581px'}, 500, function() {
            $('.prev').prop('disabled', false)    
        });
    }

    return false;
});


});

});

1 个答案:

答案 0 :(得分:1)

您需要将$('.next')$('.prev')点击绑定处理程序移出$('.pcode_btn')点击处理程序

相关问题