I've got this really annoying issue where a function returning a value of undefined every time even though the console.log() always shows that there is a value when getting into the first if statement
This is my function
function getElementIdentifier(elem, domSelector) {
if(elem.getAttribute('id') !== null) {
console.log('here');
return elem.id + ' ' + domSelector;
} else {
getElementIdentifier(elem.parentNode, elem.tagName + ' ' + domSelector);
}
}
This is how I call it
getElementIdentifier(elem, '');
Heres a fiddle to replicate it. http://jsfiddle.net/wqCSn/5/ (thanks @adeneo)