2011-04-01 88 views
1

我有這樣的代碼,我試圖使它所以它會有一個延遲,一旦你從頂部的菜單項jQuery的菜單下拉問題

$(document).ready(function() { 

    // Hover drop-downs 
    $('#header_right li ul').stop().animate({"opacity":1}, "fast"); 
    $('#header_right li ul').stop().animate({"opacity":0}, "fast"); 


    $("#header_right ul > li").hover(function(){ 
    $(this).find("ul").css('display', 'block').stop().animate({"opacity":1}, "fast"); 
    }, function(){ 
    $(this).find("ul").css('display', 'none').stop().animate({"opacity":0}, "fast"); 
    }); 

}); 

刪除鼠標任何幫助,將不勝感激

+1

什麼是你的問題? – 2011-04-01 00:46:56

+0

你有沒有考慮過hoverIntent插件? http://cherne.net/brian/resources/jquery.hoverIntent.html – Geoff 2011-04-01 01:04:43

回答

1

使用.delay()

我假設你想延遲獸皮(當鼠標懸停

您的代碼,我在第4行添加。延遲(600)。600是毫秒。

$("#header_right ul > li").hover(function(){ 
    $(this).find("ul").css('display', 'block').stop().animate({"opacity":1}, "fast"); 
}, function(){ 
    $(this).find("ul").css('display', 'none').delay(600).stop().animate({"opacity":0}, "fast"); 
}); 

更多信息:http://api.jquery.com/delay/