title: Enabling and disabling Events in javascript
body: <p>So basically I have an event that occurs at page load. it causes an image to follow your cursor, but on a click event I would like to disable this event, and then on a second click re-enable the mouse follow event</p>
  
  <p>I tried just creating a toggle variable but it just seems to be freezing my image.
   Would .on() and .off() be appropriate here? I read the documentation but I am confused on how to implement them</p>
  
  <p>I am confused as to how I would turn off an event i guess.</p>
  
  <p>Jscript</p>
  
  <pre><code>    var enabled = true;
  
          $(document).ready(function() {
              $(document).mousemove(function() {
                  if (enabled) {
                      $("#rocket").stop().animate({left:e.pageX, top:e.pageY});
                  }
              });
              $(document).click(function() {
                  enabled == !enabled;
              }); 
          });
  </code></pre>
  
  <p><a href="http://jsfiddle.net/bmzyK/2/" rel="nofollow">Demo</a></p>