2010-09-14 56 views
1

我使用以下函數從document.ready()調用,在this頁面的頂部導航欄上設置淡入/淡出效果。IE瀏覽器在jQuery中遇到問題fadeIn/fadeOut

// Initialize the main menu's rollover behavior. 
function initNavMenu(fadeInTime,fadeOutTime){ 
    $('#top-nav li').append('<div class="hover"></div>'); 

    $('#top-nav li').hover(
     function(){ 
      $(this).children('div').fadeIn(fadeInTime); 
     }, 

     function(){ 
      $(this).children('div').fadeOut(fadeOutTime); 
     }).click (function() { 
      $('#top-nav li.selected').removeClass('selected'); 
      $(this).addClass('selected'); 
    }); 
} 

它適用於FF 3.6.9,Chrome,Safari和Opera。但在IE 8上(可能還有更低的版本),當我翻轉按鈕時,會產生醜陋的墨水效果。一旦淡化完成,塗抹的效果就會消失。任何人都知道這是什麼原因?

+1

IE瀏覽器的一些醜陋的東西用透明膠片和.pngs的背景圖片爲png取出一段代碼? – Patricia 2010-09-14 17:51:58

+0

是的,但我認爲IE 7和8應該能夠處理它們。 – Alex 2010-09-14 17:53:10

+1

嘗試將這些圖像保存爲透明GIF。我遇到了類似的與IE瀏覽器(甚至7和8)的醜陋,不得不將我的一些pngs改成gif。 – Patricia 2010-09-14 18:17:26

回答

1

只要看到由開發人員工具欄在IE瀏覽器控制可見後,由於淡入淡出效果,它添加了一些不透明的代碼。只需通過編寫

$('selector').css('attribute', ''); 
or write 
$('selector').removeAttr('style'); // Removes all inline styles. 

希望這將幫助你:)

+0

謝謝,開發。開發者工具欄中的哪個位置你看到了這個? – Alex 2010-09-14 17:56:31

+1

只需搜索特定項目,在IE工具欄中進行搜索,然後在樣式選項卡中查找所有相關屬性。 – 2010-09-15 10:04:48

+0

謝謝,開發。我在哪裏可以在上面的initNavMenu()函數中添加代碼? – Alex 2010-09-15 12:45:57