0
我的问题是......当我在链接上多次移动鼠标很快,框就不会隐藏。它看起来像setTimeout被覆盖,旧的功能停止工作 - 并在最后popup_remove()不会发生。请帮忙,我是jQ的初学者,已经用这个隐藏和展示盒已经失去了将近两天的时间。当我不使用settimeout时,一切正常,只需将display:none作为mouseenter和mouseleave。我想我只是不明白setTimeout方法。jquery 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])
}