phdphd Posted January 3, 2019 Share Posted January 3, 2019 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 More sharing options...
requinix Posted January 3, 2019 Share Posted January 3, 2019 If you want to "off" an event then you have to do it with the event handler you actually attached. When you change that you'll find out that it's not all working quite as you want... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.