Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

colspan on cell do not work on collapse table when display none and again display: table-cell

Problem is when I click on the button then the cell I collapsed. That works. Then when I click one more time, then the row is colspan-1 in spite of colspan-3. What should I do to make row colspan 3 when click again. Look on border for cell a.
This is live code https://jsfiddle.net/dok6sxu4/8/

const collapseDetailsTransaction = () => {
    const details = document.getElementById(`details`);
    const caret = document.getElementById(`collapse-button`);
    if (details.style.display === "none") {
      details.style.display = "table-cell";
      caret.style.transform = "rotate(180deg)";
    } else {
      details.style.display = "none";
      caret.style.transform = "rotate(0deg)";
    }
  };
<table border="1">
    <tr>
      <td>col1</td>
      <td>col2</td>
      <td>
        <button onclick="collapseDetailsTransaction()" id="collapse-button">klik</button>
      </td>
    </tr>
    <tr id="details"><td colspan="3">a</td></tr>
</table>

gif show this problem

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

details.style.display = "table-cell";

needs to be

details.style.display = "table-row";

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading