In my code, I have a class declaration in a script that is imported before the body tag:
$(document).ready(function(){
var FamilyTree = function() {
};
FamilyTree.prototype.displayMessage=function() {
alert("test");
}
});
Then, within the body of the HTML document, I have the following code inside a script tag:
$(document).ready(function(){
var famtree= new FamilyTree();
famtree.displayMessage();
});
However, when I load the page, Firefox shows this error message:
ReferenceError: FamilyTree is not defined
Even though the class is defined before it is called, for some reason it is inaccessible. What could be causing this issue?