I want to know, how to find out recursively all parent nodes of an element. Suppose i have following snippet
Hello
Here's a shorter one:
function parentByTag(el, tag) { if(!el || el.tagName == tag) { return el } else { return parentByTag(el.parentElement, tag) } }
Returns undefined if not found.
undefined