I have an issue when I remove rows from a table.
This is the JS code I use, if it is of any help.
function rem(el) {
while (el.nodeName !== "TR") {
el = el.parentNode;
}
el.parentNode.removeChild(el);
}
The table is built like this:
<tr>
<td>
<span onclick="rem(this);"></span>
</td>
</tr>
The issue occurs when the table exceeds the browser's height and the scrollbar appears.
If the scrollbar is at the top and I remove a row, the remaining rows will flow up.
If the scrollbar is at the bottom and I remove a row, the remaining rows will flow down.
But if the scrollbar is in the middle of a table and I remove a row, the remaining rows will flow up until the scrollbar hits the bottom of the screen. Then the rows will start to flow down. I would like the table to either flow up or down. It doesn't matter which way as long as it stays consistent.
Since I remove a row by clicking on it, the table flow has to stay consistent. If the remaining rows move in different ways it's difficult for the user to predict which the next row will be, the one above or the one below.
My question is of course "How can I set in which way the remaining rows will flow after the deletion of a row?"
Let me know if I need to explain the issue further.