2012-05-09 64 views
0

我想創建一個菜單,當你點擊頁面上的任何其他地方div將被隱藏。這在一切,但Firefox的作​​品。在Firefox中,當你點擊該部分中的鏈接之一時,它不會進入鏈接,它只是關閉div。JavaScript點擊和隱藏問題火狐

代碼:

$(document).mouseup(function(e){//removes menu when clicked on any other part of page 
    if($(".menuone:visible").length > 0 ){ 
     $('.menuone').hide(); 
    } 
}); 

HTML:

<div class="menuone"> 
<div class="col1"> 
<ul><li>Example link</li></ul> 
</div> 
</div> 

回答

2

您應該建立可跟蹤.menuone div的懸停狀態的變量。

那麼你的if語句將是:

if($(".menuone:visible").length > 0 && !menuHover) 

這應該做的伎倆。

希望它能幫助:)

編輯:

var menuHover = false; 

$(".menuone").bind('mouseenter mouseleave',function(e){ 
    menuHover = e.type == 'mouseenter'; 
}); 
+0

感謝這個意願,但是這確實現在的工作 – meohmy

+0

您是否設置了一個函數來實際設置變量? – will

+0

不只是在頂部的編碼 – meohmy

0

我喜歡John Resig's網站在這裏提到的想法:

var outerPane = $details.find(".details-pane-outer"), 
    didScroll = false; 
$(window).scroll(function() { 
    didScroll = true; 
}); 

setInterval(function() { 
    if (didScroll) { 
     didScroll = false; 
     // Check your page position and then 
     // Load in more results 
    } 
}, 250);