2012-12-10 51 views
0

我使用jQuery和淡入淡出頁面上的內容片段。它會正常淡入淡出,但問題是它會在Android中自動淡入淡出之後淡出。 : - \jQuery淡入淡出作品,但馬上消失

任何想法?

$(document).ready(function(){ 
    // Fancy intro animation 
    $(".scroll-button").fadeIn(1000); 

    // Smooth the scrolling 
    $(".scroll-button").click(function(event){ 
      var bodyElement; 

      event.preventDefault(); 

      if($.browser.safari) { 
       bodyElement = $("body") 
      } else { 
       bodyElement = $("html,body") 
      } 

      bodyElement.animate({ 
       scrollTop: $('#headerimage').position().top 
      }, 500); 

      $('.bottom-image').hide(); 
      $(this.hash).fadeIn(1500); 
    }); 
}); 

回答

0

hash只屬於location對象。你試圖淡入一個不存在的元素(我懷疑jQuery構造函數實際上是$(undefined)的等價物)。

使用您發佈的代碼,$(this.hash).fadeIn(1500)正在查找.scroll-button元素的hash屬性。嘗試改變這樣的行:

$(window.location.hash).fadeIn(1500); 
+0

不幸的是,它導致它根本不會在Android中加載。在IE,Firefox,Chrome,Safari,iOS ......一切都很好,只是出於某種原因Android。 –

0

所以我發現Android 2.3不處理點擊事件,並有問題。即使附加jQuery手機(早期版本)也不起作用。

最終在圖像周圍添加一個div,然後調用div來工作。去搞清楚!