Just don't do this, i.e. calling parentNode
repeatedly without even knowing what it is. The DOM might look a lot differently than you expect. This is about as smart as not doing any range checks just for convenience.
Use a defensive & flexible approach instead (or, use a framework like jQuery to do the heavy lifting).
function closest(node, tagName) {
var parent = node.parentNode;
if (parent) {
if (parent.tagName && parent.tagName.toUpperCase() === tagName.toUpperCase()) {
return parent;
}
return closest(parent, tagName);
}
}
var container = closest(node, "table");
var firstLink = container.getElementsByTagName('a')[0];
var round1 = firstLink.innerHTML || "";