gpt4 book ai didi

javascript - 单击展开表格行

转载 作者:行者123 更新时间:2023-12-02 23:08:36 25 4
gpt4 key购买 nike

第一个 View 显示表的 3 行。接下来单击 tfoot 行并展开其他行。

$('.table-toggle .show-row').slice(3).hide();
$('#show-price').click(function() {
$('.table-toggle .show-row').show();
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tbody class="table-toggle">
<tr class="show-row">
<td width="30%" id="dollar-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span> 1,00</td>
<td width="30%" id="sell-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span></td>
<td width="30%" id="dollar-price"></td>
<td width="30%" id="sell-price"></td>
<td width="20%" class="table-action">
<button data-value="ripple" class="btn btn-sm btn-primary charge-btn st-btn"></button>
<button data-value="ripple" class="btn btn-sm btn-warning ml-1 sell-btn st-btn"></button>
</td>
</tr>
</tbody>
<tfoot id="show-price" style="cursor: pointer">
<tr>
<th> ...</th>
</tr>
</tfoot>

最佳答案

$('.table-toggle .show-row').slice(3).hide();
$('#show-price').data('hidden', true);
$('#show-price').click(function() {
if ($(this).data('hidden')) {
$('.table-toggle .show-row').show();
$(this).data('hidden', false);
} else {
$('.table-toggle .show-row').slice(3).hide();
$(this).data('hidden', true);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tbody class="table-toggle">
<tr class="show-row">
<td width="30%" id="dollar-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span> 1,00</td>
<td width="30%" id="sell-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span></td>
<td width="30%" id="dollar-price"></td>
<td width="30%" id="sell-price"></td>
<td width="20%" class="table-action">
<button data-value="ripple" class="btn btn-sm btn-primary charge-btn st-btn"></button>
<button data-value="ripple" class="btn btn-sm btn-warning ml-1 sell-btn st-btn"></button>
</td>
</tr>
<tr class="show-row">
<td width="30%" id="dollar-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span> 1,00</td>
<td width="30%" id="sell-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span></td>
<td width="30%" id="dollar-price"></td>
<td width="30%" id="sell-price"></td>
<td width="20%" class="table-action">
<button data-value="ripple" class="btn btn-sm btn-primary charge-btn st-btn"></button>
<button data-value="ripple" class="btn btn-sm btn-warning ml-1 sell-btn st-btn"></button>
</td>
</tr>
<tr class="show-row">
<td width="30%" id="dollar-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span> 1,00</td>
<td width="30%" id="sell-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span></td>
<td width="30%" id="dollar-price"></td>
<td width="30%" id="sell-price"></td>
<td width="20%" class="table-action">
<button data-value="ripple" class="btn btn-sm btn-primary charge-btn st-btn"></button>
<button data-value="ripple" class="btn btn-sm btn-warning ml-1 sell-btn st-btn"></button>
</td>
</tr>
<tr class="show-row">
<td width="30%" id="dollar-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span> 1,00</td>
<td width="30%" id="sell-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span></td>
<td width="30%" id="dollar-price"></td>
<td width="30%" id="sell-price"></td>
<td width="20%" class="table-action">
<button data-value="ripple" class="btn btn-sm btn-primary charge-btn st-btn"></button>
<button data-value="ripple" class="btn btn-sm btn-warning ml-1 sell-btn st-btn"></button>
</td>
</tr>
<tr class="show-row">
<td width="30%" id="dollar-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span> 1,00</td>
<td width="30%" id="sell-price"><span class="fa fa-arrows-alt-h" style="color: blue"></span></td>
<td width="30%" id="dollar-price"></td>
<td width="30%" id="sell-price"></td>
<td width="20%" class="table-action">
<button data-value="ripple" class="btn btn-sm btn-primary charge-btn st-btn"></button>
<button data-value="ripple" class="btn btn-sm btn-warning ml-1 sell-btn st-btn"></button>
</td>
</tr>
</tbody>
<tfoot id="show-price" style="cursor: pointer">
<tr>
<th> Click to show/hide...</th>
</tr>
</tfoot>
</table>

关于javascript - 单击展开表格行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57476722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com