【发布时间】:2014-04-10 15:19:54
【问题描述】:
我的问题是......当我在链接上多次快速移动鼠标时,框只是不隐藏。看起来 setTimeout 被覆盖并且旧功能停止工作 - 最后 popup_remove() 没有发生。请帮忙,我是 jQ 的初学者,已经用这个隐藏和显示框迷失了将近两天。当我不使用 settimeout 并且只为 mouseenter 和 mouseleave 放置 display:none 时,一切都很好。我想我只是不明白 setTimeout 方法。
我的 JS:
timeout_on = {};
timeout_off = {};
$('.flex_section').delegate('a','mouseenter mouseleave',function(e){
var a = $(this).attr('id')
if (e.type == 'mouseenter'){
timeout_on['id_'+ a] = setTimeout(function() { popup_show(a); }, 300);
} else {
timeout_off['id_'+ a] = setTimeout(function() { popup_remove(a); }, 300)
}
});
popup_show(type){
$('#someID_' + type).css('display','block')
clearTimeout(timeout_on['id_'+ type])
}
popup_remove(type){
$('#someID_' + type).css('display','none')
clearTimeout(timeout_off['id_'+ type])
}
【问题讨论】:
标签: jquery settimeout