問題是當我點擊按鈕然后我折疊的單元格。這樣可行。然后,當我再單擊一次時,盡管 colspan-3,該行仍為 colspan-1。再次單擊時,我應該怎么做才能使 row colspan 3。在邊框上查看單元格 a。這是實時代碼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 顯示這個問題
uj5u.com熱心網友回復:
details.style.display = "table-cell";
需要是
details.style.display = "table-row";
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/400627.html
標籤:javascript html css
上一篇:單擊不同專案時切換展開/折疊箭頭
