2012-10-11 47 views
1

我有這塊代碼。這個想法是,當我mouseoverli#anchor,以前隱藏ul#seeMore應該顯示出來。使用mouseover和jQuery顯示/隱藏

jQuery(document).ready(function(){ 
    jQuery("li#anchor").mouseenter(function() { 
     jQuery('ul#seeMore').css("display","block"); 
    }); 

    jQuery("li#anchor").mouseleave(function() { 
     setTimeout(function(){ 
      jQuery('ul#seeMore').css("display","none");    
     },1000); 
    }); 
}) 

的問題是,我也希望,第二mouseleave功能不應該或發生,如果我仍然徘徊在ul#seeMore

,可能的問題應該是:我怎樣才能確定,如果我不徘徊在ul#seeMore

我試圖將jQuery("li#anchor").mouseleave(function() {更改爲jQuery("ul#seeMore").mouseleave(function() {但似乎這不是很穩定。

+0

我做了這個renato,即使我將它徘徊,我仍然失去ul。另一個問題是我無法將ul#seeMore定位在其他相鄰的div上方。 – Jeremy

+0

你能告訴我們html代碼嗎?如何構建ul/li元素 –

回答

0

您可以將ul#seemore放入li#anchor元素內。這樣,當鼠標達到ul#seemore時,它將會是li#anchor元素

+0

好,實際上它解決了我的問題。你有解決我的其他問題嗎?像定位ul上面的其他元素? z-index不起作用。 – Jeremy

+1

我現在還不確定。 Z-index應該可以工作... –

+0

你其實是對的Renato,Z-index正在工作,我可能把事情搞砸了。 – Jeremy