2012-11-29 26 views
1

我剛剛發現我的腳本在Chrome中工作正常,但沒有在FireFox中 - 我找不出原因。Jquery/Javascript無法在Firefox上工作。爲什麼?

這是發展中的網站:www.fireflycovers.com

當點擊綠色圓形按鈕的一個腳本應該執行。 (滾動窗口下一個容器)

腳本看起來像這樣的時刻:

$('.scroll').css('display' , 'block'); 
$('.scroll').on('click', function(e) { 
    var container = $(this).parent(); 

    // Scans if last container in group 
    while (document != container[0] && 
      container.find('~.col, ~:has(.col)').length == 0) { 

      // If so, search siblings of parent instead 
      var container = container.parent(), 
       nextdiv = container.nextAll('.col, :has(.col)').first(); 
    } 

    // Back to first .col (when no next .col) 
    if (nextdiv.length == 0) { 
     nextdiv = $(document).find('.col:first') 
    }; 

    // Animates scrolling to new position 
    $('body').animate({scrollTop:nextdiv.offset().top}, 1000); 
     return false; 
    }); 
}); 

回答

0

你嘗試調試呢?如同,在你的方法中加入console.log的陳述,看看事物的價值在某些時候是什麼,並觀察它的執行?無論如何,使用這個幫助呢?

$('body,html').animate({scrollTop:nextdiv.offset().top}, 1000); 

驗證從Animate scrollTop not working in firefox

你需要html因爲Firefox的行爲不同,當談到overflow

+1

太棒了!你是英雄! :-D – Arrowcatch

+0

@Arrowcatch哈哈沒問題,很高興爲你修好了! – Ian

相關問題