当用户将鼠标悬停在其上并向外滑动鼠标时,我会向下滑动一些内容。我的问题是当我经常移动鼠标直到它的滑动或滑动它没有显示。意味着它正在创建一个队列。
$(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);
}
);
});
答案 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);
}
);
});