【问题标题】:Jquery settimeout multiple timesjQuery settimeout 多次
【发布时间】: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


    【解决方案1】:

    也许您必须先清除超时,然后再设置另一个??

    鼠标输入: - 添加超时进入 鼠标离开: - 删除旧的超时 - 为离开添加超时 ...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-19
      • 1970-01-01
      相关资源
      最近更新 更多