2012-04-07 133 views
0

如果用戶在課堂上移動鼠標兩秒(保持鼠標按鈕兩秒),我想要顯示他隱藏課程。怎麼樣? ()jquery在2秒後顯示延遲

如果您在類上移動鼠標串聯(多次),您將看到slideToggle完成爲自動化,我不想要這樣做。如何解決它?

DEMO:http://jsfiddle.net/tD8hc/

我試過:

$('.clientele-logoindex').live('mouseenter', function() { 
    setTimeout(function(){ 
     $('.clientele_mess').slideToggle("slow"); 
    }, 2000); 
}).live('mouseleave', function() { 
     $('.clientele_mess').slideUp("slow"); 
})​ 

回答

1

請試試這個下面的鏈接您的問題將解決

http://jsfiddle.net/G3dk3/1/ 

變種S;
$( '客戶-logoindex ')。住(' 的mouseenter',函數(){

s = setTimeout(function(){ 
     $('.clientele_mess').slideDown(); 
    }, 2000); 
}).live('mouseleave', function() { 
     $('.clientele_mess').slideUp("slow"); 
    clearTimeout(s) 
}) 
+0

在此處發佈您的答案,而不僅僅是在其他網站上。 – 2012-04-07 18:40:20

+0

它會工作請嘗試此代碼 – Mahipal 2012-04-07 18:40:56

+0

已添加代碼只在這裏 – Mahipal 2012-04-07 18:47:16

0

寫你的HTML這樣

<div class="clientele-logoindex">Keep the mouse here 
<div class="clientele_mess" style="display: none;">okkkkkkko</div></div> 
+0

它在滑動窗口中出現問題後,將鼠標移動到類「clientele-logoindex」上,並自動完成。 – 2012-04-07 18:39:19

0

記錄時啓動一個定時器,檢查一個開始新的存在之前一個:

window.timer = null;  
$('.clientele-logoindex').live('mouseenter', function() { 
    if(!window.timer) { 
     window.timer = setTimeout(function(){ 
      $('.clientele_mess').slideToggle("slow"); 
      window.timer = null; 
     }, 2000); 
    } 
}).live('mouseleave', function() { 
     $('.clientele_mess').slideUp("slow"); 
})​