I'm writing a js recursion function to find all ancestors of an element a user clicked on. my code is like this:
/**a global variable.*/
var anc; 
function getAncestors(e){  
 var ele = e.target; 
 var parentName = ele.parentNode.name;    
 anc +=bracket(parentName); 
 if (parentName.toLowerCase() == "undefined" ) return;    
 else getAncestors(parent);     
}
I ran it using firefox, but there's an error message in the error console, "Error: ele.parentNode is undefined".
also, when i reset anc = ' '; it didn't work either.
Thanks!
Paul