2010-05-10 25 views
0

我有三個層次的ul li。想要增加懸停效果的延遲時間

<ul> 
    <li> 
    <li> 
    <ul> 
     <li> 
     <li> 
      <ul> 
      <li> 

我想增加懸停定時即當我將鼠標懸停在第二級裏的延遲時間懸停必須增加,直到我達到其子女即第三級

+2

我不知道你在說什麼。 – animuson 2010-05-10 06:57:49

+0

我想他是在談論某種下拉菜單。 – ThiefMaster 2010-05-10 08:31:34

回答

0

假設你有使用javascripe代碼mouseover()/mouseout()hover(): 獲取hoverIntent插件和使用element.hoverIntent(overfunc, outfunc)

0

當你使用jQuery,確保你使用mouseentermouseleave,而不是mouseovermouseout在這些情況下。 mouseovermouseout即使進入子元素。如果您有隱藏代碼的代碼,那麼您不希望它在當前的菜單中運行,您希望它在完全離開<li>時運行,並且認爲孩子仍然在裏面......這就是mouseentermouseleave做:)

還有一個快捷方式對該被叫.hover()它使用mouseentermouseleave這樣的活動:

$(selector).hover(mouseenterFunc, mouseleaveFunc); 

下面是一個例子:

$("li").hover(function() { 
    $(this).children("ul").slideDown(); 
}, function() { 
    $(this).children().slideUp(); 
}); 

You can see the above code in a quick demo against your posted tree here