Jump to content

Jquery Fire Event On Mousemove Only Once


phdphd

Recommended Posts

Hi all,

I want to make a div follow the mouse vertical position, with some fading effect. It turns out that the code does not stop running despite the "off" method. I would like to make it run just once every time the mouse is moved. Thanks!


	$(document).on('mousemove', 
 function(e){
	 $( "#nav2" ).delay(2000).fadeIn(1000).delay(2000).fadeOut(1000);
	$('#nav2').css({top:y = e.pageY});
	$('#nav2').off('mousemove');

});

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.