I've hunted around for about an hour or so trying to glean whatever I could about variable scope in jscript/jquery and by all accounts, my code should work. Right now I just want to be able to read a global variable from a function. My code isn't working and right now it's very basic. Eventually I will need to manipulate the global variable, but one step at a time here:
var fooBar;
fooBar = "blah";
$('.var').click(function (fooBar) {
alert(fooBar);
});
HTML:
<span class="var">(Button Test)</span>
It returns [Object object] in the alert box. I was really hoping it would return Blah for me. I know this is a very very basic question, but all examples I'm finding are pretty complex and it's pretty difficult for me to boil it down to the very basic part that I need. Any help is greatly appreciated.