gpt4 book ai didi

javascript - 使用 + 和 - 图标折叠/展开表格

转载 作者:行者123 更新时间:2023-11-28 01:09:58 24 4
gpt4 key购买 nike

下面是我用来展开和折叠表格的脚本。这工作正常,但我现在需要知道如何在表格展开和折叠时将文本从 + 更改为 - 。我想避免为这些图标使用图像。任何建议都会很棒!谢谢:)

<script type="text/javascript">
jQuery(document).ready(function ()
{
jQuery(".content").hide();
jQuery(".collapselabel").click(function ()
{
Query(this).next(".content").slideToggle(200);
});
});
</script>

这是我的标签和表格

<div class="collapselabel">
<label> + Shops </label>
</div>
<div class="content">
<table>
<tr>
<td width="400">
Shop One
</td>
<td width="400">
Shop Two
</td>
<td width="400">
Shop Three
</td>
</tr>
</table>
</div>

最佳答案

执行此操作的快速方法是

<script type="text/javascript">
jQuery(document).ready(function ()
{
jQuery(".content").hide();
jQuery(".collapselabel").click(function ()
{
Query(this).next(".content").slideToggle(200);
if($(".collapselabel label").html() == " + Shops")
$(".collapselabel label").html() == " - Shops";
else
$(".collapselabel label").html() == " + Shops";
});
});
</script>

关于javascript - 使用 + 和 - 图标折叠/展开表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24576289/

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