jquery - Delay hover animation -


this question has answer here:

my code is:

$(document).ready(function() {     $('.holder').hover(function() {         $(this).find('.heading').slideup();      },function() {         $(this).find('.heading').slidedown();     }); }); 

now want implement settimeout function. problem $(this)

just store $(this) in variable , use variable within anonymous function:

$(document).ready(function() {     $('.holder').hover(function() {         var $self = $(this);         settimeout(function(){           $self.find('.heading').slideup();          }, 500);     },function() {         $(this).find('.heading').slidedown();     }); }); 

edit in response comments:

$(document).ready(function() {     var timer;     $('.holder').hover(function() {         var $self = $(this);         timer = settimeout(function(){           timer = false;           $self.find('.heading').slideup();          }, 2000);     },function() {         if(timer){             cleartimeout(timer);             timer = false;         }else{             $(this).find('.heading').slidedown();         }     }); }); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -