2011-11-26 40 views
0

我滑下一些內容時,用戶鼠標懸停在上面,滑出鼠標。我的問題是,當我經常移動鼠標直到它滑動或滑動它不顯示。意味着它正在創建一個隊列。jquery Slidedown製作隊列

$(function(){ 
    $('div[tooltip="true"]').hover(
     function(e){ 
      x = e.clientX; 
      y = e.clientY; 
      newX = x + 10; 
      newY = y + 5; 
      $('#tool_tip_text_content').css({'left':newX, 'top':newY}); 
      html_content = '<p>Some Html content</p>'; 
      $('div#tool_tip_text_content').html(html_content); 
      $('#tool_tip_text_content').slideDown(500); 
     }, 
     function(e){ 
      $('div#tool_tip_text_content').html(''); 
      $('#tool_tip_text_content').slideUp(0); 
     } 
    ); 
}); 

回答

1

您應該使用jQuery.stop來停止當前的隊列。您的代碼應該看起來像:

$(function(){ 
    $('div[tooltip="true"]').hover(
     function(e){ 
      x = e.clientX; 
      y = e.clientY; 
      newX = x + 10; 
      newY = y + 5; 
      $('#tool_tip_text_content').css({'left':newX, 'top':newY}); 
      html_content = '<p>Some Html content</p>'; 
      $('div#tool_tip_text_content').html(html_content); 
      $('#tool_tip_text_content').stop(true, true).slideDown(500); 
     }, 
     function(e){ 
      $('div#tool_tip_text_content').html(''); 
      $('#tool_tip_text_content').stop(true,true).slideUp(0); 
     } 
    ); 
}); 
+0

如果我只使用停止它不起作用。但是如果我使用stop(true,true)而不是它的作用。 –

+0

正如文檔中所述,.stop([clearQueue] [,jumpToEnd]),您可以將這兩個變量用於多種用途。 –

+0

謝謝你讓我進入解決方案的基地。非常感謝。 –