让我说(我简化了)我有4格与内容... 我喜欢淡入淡出/隐藏它们,如果鼠标不动2秒 和当鼠标再次...让我们quikly使一切再次出现...jquery timeout解决方案?
jquery中有多简单?
我不是真的习惯于timetout和鼠标..更多的css用于!
我谷歌的 “概念”,并发现:Hide div element with jQuery, when mouse isn't moving for a period of time?
我会进行调查,如果工作!
让我说(我简化了)我有4格与内容... 我喜欢淡入淡出/隐藏它们,如果鼠标不动2秒 和当鼠标再次...让我们quikly使一切再次出现...jquery timeout解决方案?
jquery中有多简单?
我不是真的习惯于timetout和鼠标..更多的css用于!
我谷歌的 “概念”,并发现:Hide div element with jQuery, when mouse isn't moving for a period of time?
我会进行调查,如果工作!
您需要创建一个run-a-way计时器,该计时器会在每个鼠标移动时重新启动。
$(document).bind('mousemove', function() {
var $somediv = $('#somediv');
return function() {
if(!$somediv.is(':visible'))
$somediv.fadeIn('slow');
this.tID && clearInterval(this.tID);
this.tID = setTimeout(function() {
$somediv.fadeOut('slow');
}, 2000);
};
}());
最终的解决方案......和容易的:http://paulirish.com/2009/jquery-idletimer-plugin/ 的jquery.idle-timer.js
使用clearTimeout和超时到期时,你应该清楚的tID ,所以在过期后你不清除它。而且,在每次鼠标移动时清除并设置Timeout效率都很低,但这是一个快速解决方案。 – Amir 2011-01-25 21:36:48