【发布时间】:2013-01-27 20:19:46
【问题描述】:
如果我将鼠标悬停在一个元素上超过 5 秒,我想显示一个 div,我尝试了一些在 stackoverflow 中发布的解决方案,但它们都不起作用。
这是我没有超时的悬停功能
$('div.avatar-with-data, .q-item-avatar').hover(function(){
$(this).find('div.user-data').fadeIn('fast');
},function(){
$(this).find('div.user-data').fadeOut('fast');
});
更新
没有答案有效,但如果我改变了
$(this).find('div.user-data').fadeIn('fast');
到
alert('shown');
然后它起作用了(不明白为什么,尝试将 fadeIn 更改为 show() 但仍然没有运气)。 但是我上面的悬停功能可以在没有超时的情况下工作。
【问题讨论】:
-
他们为什么不工作?使用超时有什么问题?
-
这正是 hoverIntent 所做的,幸运的是 hoverIntent 语法基本上类似于 hover