Accessing a variable set in jquery.ready (from outside the jquery block)

Accessing a variable set in jquery.ready (from outside the jquery block)

I am trying to access a variable that needs to be set inside the ready code. The variable doesn't get set as I expect - I'm never able to see the value 5 for testVar. What am I doing wrong?

 

<script type="text/javascript">

testVar = 1; // Decalred globally
$(document).ready(function() {
  testVar = 5;
});

alert("Value: " + testVar); // Always returns 1 not 5 - why?

</script>