2012-08-08 23 views
1

我使用jQuery創建了DropDown菜單。除了IE7,一切都很好。根本不工作。它只是使最後一個環節大膽。我不知道如何調試它。顯示/隱藏菜單在IE7中不起作用

我創建this fiddle.

有沒有人有辦法解決嗎?

這是JS不工作:

$(".link-dropdown").on({ 
     click: function(){ 
      var $this = $(this); 

      if ($this.parent().next().is(":visible")){ 
       $('.opening-holder').hide(); 
       $('.link-dropdown').css({ 
        'fontFamily': 'Geogrotesque-Regular, Arial, sans-serif' 
       }); 
      } else { 
       $('.opening-holder').hide(); 
       $('.link-dropdown').css({ 
        'fontFamily': 'Geogrotesque-Regular, Arial, sans-serif' 
       }); 

       $this.css({ 
        'fontFamily': 'Geogrotesque-SemiBold, Arial, sans-serif' 
       }); 

       $this.parent().next().show(); 
       $this.parent().next().children().show(); 
      } 

      return false; 
     } 
    }); 
+0

在這裏發佈相關的代碼,並添加一個體面的問題描述。 「根本不工作」不是**錯誤信息**,也不是**問題描述**。 – PeeHaa 2012-08-08 11:14:42

+0

我添加了一些更多信息。我用例子創建了小提琴 – bla0009 2012-08-08 11:17:44

+0

這是解決方案 http://jsfiddle.net/EMnw3/27/ – bla0009 2012-08-08 12:11:31

回答

0

這是一個與你已經使用:visible的事實做。

+0

我把$ this.parent()。next()。(「:not(:hidden)」)代替(): if($ this.parent()。next()。is(「:visible」)) 並且不起作用 – bla0009 2012-08-08 11:39:20

+0

對不起 - 我不敢相信我添加了一個鏈接到一個糟糕的SO回答! – McNab 2012-08-08 11:44:44

0

試試這個:

我剛纔所做的更改將jQuery腳本和它的工作如下:

$(function(){ 
    $(".link-dropdown").on({ 
     click: function(){ 
      var $this = $(this); 

      if ($this.css("dispaly") == "block;"){ 
       $('.opening-holder').hide(); 
       $('.link-dropdown').css({ 
        'fontFamily': 'Geogrotesque-Regular, Arial, sans-serif' 
       }); 
      } else { 
       $('.opening-holder').hide(); 
       $('.link-dropdown').css({ 
        'fontFamily': 'Geogrotesque-Regular, Arial, sans-serif' 
       }); 

       $this.css({ 
        'fontFamily': 'Geogrotesque-SemiBold, Arial, sans-serif' 
       }); 

       $this.parent().show(); 
       $this.parent().children().show(); 
      } 

      return false; 
     } 
    }); 
}); 
+0

這現在不適用於Chrome,只能在IE中使用 – bla0009 2012-08-08 11:38:15