I'm having trouble understanding jQuery variable scope.
var myVar;
function getMyVar() {
myVar = 'test';
}
$(window).load(function() {
getMyVar();
});
alert(myVar);
This code will alert 'undefined' and I need it to show 'test' and I want to understand my scope issues here.