私は一日中この問題に苦しんでいます。
クリックするとフィールドにフェードインするjQueryボタンがあります。このフィールドは、左に 3 回、右に 3 回スクロールするスクロール可能なテーブルです。
スクロールの長さはコンテナーのサイズ (overflow:hidden) に関連していますが、元のボタンをもう一度クリックしない限り、すべてが正常に機能するという問題があります。このボタンをクリックするたびに、各方向のスクロール距離の値が 2 倍になります。ボタンがイベントを 2 倍にしているかのようです。
$(document).ready(function(){
$('.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;
});
});
});