Reputation: 2154
I have a slide thing and I only want the #content div to slide up after the mouse has been out of .content for more than 2 seconds. but i want to be able to put my mouse back over, if it is within those 2 seconds. Here is the fiddle - http://jsfiddle.net/YZDGu/.
Upvotes: 0
Views: 2006
Reputation: 1726
Updated your fiddle here with use of set/clearInterval.
See setInterval and clearInterval.
Upvotes: 1
Reputation: 298430
Use setTimeout
and clearTimeout
:
var slideTimer;
$(".container").hover(function(){
$('#content').slideDown();
clearTimeout(slideTimer);
},function(){
slideTimer = setInterval(function() {
$('#content').slideUp();
}, 2000);
});
Demo: http://jsfiddle.net/GFpHH/
Upvotes: 4
Reputation: 1948
Add a delay:
$(".container").hover(function(){
$(".container #content").slideDown();
},function(){
$(".container #content").delay(2000).slideUp();
});
Upvotes: 1