【问题标题】:Removing the class "in" in the bootstrap accordian dynamically when clicked on the button单击按钮时动态删除引导手风琴中的“in”类
【发布时间】:2017-04-11 10:09:53
【问题描述】:

当点击按钮时,必须动态删除 div 元素中的“in”类。

<div class="container">
  <h2>Simple Collapsible</h2>
  <p>Click on the button to toggle between showing and hiding content.</p>
  <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo">Simple collapsible</button>
  <div id="demo" class="collapse in">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
  </div>
</div>

【问题讨论】:

    标签: angular bootstrapping


    【解决方案1】:

    您可以在 app.component.ts 中分配一个布尔值,并在单击按钮时在 true 或 false 之间更改值

    <button (click)="isVisible = !isVisible">Toggle</button>
    

    然后在 div 中添加以下内容

    <div id="demo" [ngClass]="{'in': isVisible}" class="collapse">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-19
      • 1970-01-01
      • 2019-01-19
      • 1970-01-01
      • 2019-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多