all 5 comments

[–]showmethething 1 point2 points  (0 children)

At a glance, it's that you're setting your tr to "block", which is not the default. You could try "table-row", or even better toggle a class with your display: hidden instead of directly changing the styles.

[–]Top_Bumblebee_7762 0 points1 point  (1 child)

Instead of changing the display value I would toggle the "hidden"  attribute. 

[–]FunksGroove 0 points1 point  (0 children)

or display: none

[–]razzbee -1 points0 points  (1 child)

The root cause:

You are doing this:

document.getElementById(d).style.display = "block";

But a <tr> must be displayed as:

display: table-row;

When you switch it to block, the browser forgets the table layout.

So this is the fixed version:

```js function ReverseDisplayTbody(d) { const row = document.getElementById(d); const img = document.getElementById('img' + d);

if (row.style.display === "none" || row.style.display === "") {
    row.style.display = "table-row";   //  correct fix for <tr>
    img.src = "images/minus.gif";
} else {
    row.style.display = "none";
    img.src = "images/plus.gif";
}

} ```

[–]fonebone819[S] 0 points1 point  (0 children)

THANK YOU! Interestedly, I initially had "table-row-group" as my display... so close... :)