I have a simple .slideDown
function:
$globalTabs.find('.seeMore a').live("click", function(){
$globalTabs.find(".allTabs").slideDown('slow');
});
When a user clicks on an <a>
in .allTabs
,.allTabs
does a .slideUp
.
What I want to do, is if a user has not clicked anything in .allTabs
and the mouse is no longer within .allTabs
, then a timer initiates to wait x amount of time and then do the .slideUp
. Additionally, if the mouse enters .allTabs
again before the .slideUp
triggers - then the timer is stopped and resets when the mouse is moved outside of .allTabs
Not sure how to approach. Any help would be appreciated.
base markup:
<div class="allTabs">
<a href="#">link 1</a>
<a href="#">link 2</a>
<a href="#">link 3</a>
<a href="#">link 4</a>
</div>
and:
<li class="seeMore"><a href="#">see more</a></li>
Set a timer to do the
slideup
in the callback of theslidedown
and onmouseout
of.allTabs
. Cancel the timer onmouseover
on.allTabs
.
Try this way:
You can use
setTimeout
andclearTimeout
functions, note thatlive
method has been deprecated, you can use theon
method instead.Fiddle
Update:
Fiddle