简体   繁体   English

当显示无并再次显示时,单元格上的 colspan 在折叠表上不起作用:table-cell

[英]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.然后,当我再次单击时,尽管有 colspan-3,但该行是 colspan-1。 What should I do to make row colspan 3 when click again.再次单击时,我应该怎么做才能使行 colspan 3。 Look on border for cell a.在边框上查找单元格 a。 This is live code https://jsfiddle.net/dok6sxu4/8/这是实时代码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 gif 显示这个问题

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

needs to be需要是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM