Accessing variables outside of function?
Ugghh - I don't know what I'm doing wrong - probably pertains more to Javascript than jQuery.
$(document).ready(function(){
var myVar = 0;
$("#myButton").click(function(event){
myVar++;
});
$("#myButton2").click(function(event){
alert(myVar); //this returns 'undefined' Why? :(
});
});
Why can't I access the 'myVar' variable my clicking 'myButton2' ??