Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
I have some Javascript which mostly works except this one function which I can call from some areas but not others. It appears to be a scope issue but I don't know why.
$().ready(function () {
UpdateElfDisplay(); // <--- Undefined
$('#Attribute1').change(function () {
UpdateElfDisplay(); // <--- Works just fine.
});
var UpdateElfDisplay = function () {
// ... some work done here
};
});
As I marked above, the UpdateElfDisplay function works fine when I call it from .change() function but I get an "undefined" if I try to call it when the document is loaded. Can somebody explain why, or direct me to a resource describing this.