S
samuelberthelot
Hi,
Here's the function:
function getParentElementByTagName(child, TagName){
var cn;
if (child.parentElement){
cn = child.parentElement;
if (child.parentElement.tagName == TagName){
return cn;
}else{
getParentElementByTagName(child.parentElement, TagName);
}
}
}
although it finds the element, the function returns null ( on the line
'return cn', cn is not null though). Is my algorithm wrong ?
thanks
Here's the function:
function getParentElementByTagName(child, TagName){
var cn;
if (child.parentElement){
cn = child.parentElement;
if (child.parentElement.tagName == TagName){
return cn;
}else{
getParentElementByTagName(child.parentElement, TagName);
}
}
}
although it finds the element, the function returns null ( on the line
'return cn', cn is not null though). Is my algorithm wrong ?
thanks