0

UPDATE: Please reffeer to this Question: How to hide an iframe (that is following the mouse) when it passes over a link? (Best Solution)

im trying to make a function that an object follows the mouse everywhere on the screen, but when the mouse hovers a link, the mousemovement must stop, so the object that is following the mouse does not interfeer when clicking the link. To do that i created a #safe css to use as my links id. Im trying to unbind and bind the 'mousemove', it unbinds when mouse is over the link, but does not bind back when the mouse leaves the link. How can i solve that?

here my fiddle: http://jsfiddle.net/czdpY/

$('#safe').hover(
    function () {
        $(document).unbind('mousemove');
    },
    function () {
        $(document).bind('mousemove');
    }
); 
Community
  • 1
  • 1
Lucas Matos
  • 1,112
  • 5
  • 25
  • 42
  • 1
    Damn, [you got to read this](http://stackoverflow.com/a/10777211/601179)! mouse event on the `document`, Are you mad ?! Do you know how many times it will fire? jQuery devloper: _"...But people used to do things like $().mouseover() and all sorts of other madness. ..."_ – gdoron May 29 '12 at 21:25
  • @gdoron, ok. so how can i do that? can you explain to me? im no expert.. im just starting to work with jquery.. – Lucas Matos May 30 '12 at 18:00
  • That's depends on what exactly you're trying to do. a DEMO could help us understand better. – gdoron May 30 '12 at 19:19
  • @gdoron, heres the demo im trying: http://jsfiddle.net/czdpY/ thanks – Lucas Matos May 30 '12 at 21:09
  • pls guys look at my demo. now im trying to make the frame display:none when mouse cursor is over a link. – Lucas Matos May 31 '12 at 16:51

1 Answers1

1

You need to add the function names as well.

$('#safe').hover(
  function () {
    $(document).unbind('mousemove', boundFunction);
  },
  function () {
    $(document).bind('mousemove', boundFunction);
  }
); 
ahren
  • 16,803
  • 5
  • 50
  • 70