Suppose I have a table, some rows and cells.
If I click a cell and I need to go to the table node I can do something like:
while (tcel) {
if (tcel.nodeName === "TABLE") {
tbl = tcel;
break;
}
else {
tcel = tcel.parentElement;
// tcel will be lost
}
}
I'm wondering if there's a way I can get to the table node without the loop, but instead if there's a method that knows that the tcel belongs to the table, like a relative parent?