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

Collapse/expand table with + and - icons

本文关键字:表格 折叠 图标      更新时间:2023-09-26

下面是我用来展开和折叠我的表的脚本。这工作得很好,但我现在需要知道如何我可以改变我的文本从+到-当表展开和崩溃。我想避免在这些图标中使用图像。任何建议都会很好!谢谢:)

<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>