I wrote a similar function, but mine was to find the parent form:
function parentForm(node) { if (node==document) return false; if (node.tagName=="FORM") return node; return parentForm(node.parentNode); }
I kinda like it, as it's very simple - and uses recursion to make it even simpler. I don't know if there's a limit in JavaScript to the number of stack that can be recursed.
Comment
I wrote a similar function, but mine was to find the parent form:
function parentForm(node) {
if (node==document) return false;
if (node.tagName=="FORM") return node;
return parentForm(node.parentNode);
}
I kinda like it, as it's very simple - and uses recursion to make it even simpler. I don't know if there's a limit in JavaScript to the number of stack that can be recursed.