【问题标题】:Collapse/expand table with + and - icons使用 + 和 - 图标折叠/展开表格
【发布时间】:2014-07-04 22:26:18
【问题描述】:

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

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

【问题讨论】:

    标签: javascript jquery html


    【解决方案1】:

    一个快速的方法是

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-12
      • 2016-08-23
      • 2012-04-05
      • 1970-01-01
      • 2014-11-24
      • 2020-10-06
      • 1970-01-01
      相关资源
      最近更新 更多