Return to Snippet

Revision: 44834
at April 19, 2011 21:04 by pedromagalhaes


Initial Code
$(this).mouseover(function(){	
	
	$seconds = 0;
	$timer = 0;
	count();	
	
	function count(){		
		$seconds = setTimeout(function() {
			count();
		}, 1000);			
		$timer = $timer + 1;							
		if($timer == 2){			
			// your code goes here...		
			clearTimeout($seconds);			
		}		
	}							
	
}).mousemove(function(kmouse){			
	if($timer == 2){			
		// your code goes here...
		clearTimeout($seconds);			
	}	
}).mouseout(function(){	
	clearTimeout($seconds);	
	// your code goes here...	
});

Initial URL


Initial Description
I created this snippet for a personal project, where i needed to open a tooltip only when the user was over or moving the mouse after X seconds in a specific selector.
In the code you will find "your code goes here" where you can play around like showing or hiding divs, or whatever are your needs.

Initial Title
Execute something if over something after X seconds

Initial Tags


Initial Language
jQuery