title: jquery/javascript - accessing variables from outside a function
body: <p>I'm trying to use a variable value outside of the function it was defined in. Thought I. just needed to declare the variable outside the function but that doesn't cut it. Gotta be an easy one for those who know?<br>
  <br>
  <a href="http://jsfiddle.net/xSa2T/" rel="nofollow noreferrer">Fiddle Here</a></p>
  
  <pre><code>jQuery(document).ready(function() {
  
      var readOut;
      var readOut2;
  
      $(document).mousemove(function(e) {
          readOut1 = e.pageX;
          readOut2 = e.pageY;
          $('#var1').html(readOut1);
  
      });
  
      $('#var2').html(readOut2);
  })​
  </code></pre>
  
  <p>Thanks to all, especially Andy E with the explaination and <a href="http://jsfiddle.net/FrVjd/" rel="nofollow noreferrer">solution</a>.</p>