如何确定引导崩溃是打开还是关闭? [英] How to determine if a bootstrap collapse is opening or closing?

查看:52
本文介绍了如何确定引导崩溃是打开还是关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我发生了自举崩溃,如何从点击事件中确定崩溃是打开还是关闭?

If I have a bootstrap collapse how can I determine from a click event wether the collapse is opening or closing?

这是我的点击事件,或者也许有比使用点击事件更好的方法了?

Here is my click event or maybe there is a better way then to use a click event?

$(document).on("click", "a.register-student-link", function() {
    // do some stuff to check if opening or closing
}

<div>
  <a id=@space.EventId class="register-student-link" data-toggle="collapse" href=@spaceIdWith aria-expanded="false" aria-controls="collapseExample">
                                                    Register Student
                                                </a>
</div>

推荐答案

如果该区域是否折叠,Bootstrap使用aria-expanded属性显示true或false.

Bootstrap uses the aria-expanded attribute to show true or false if the region is collapsed or not.

var isExpanded = $(collapsableRegion).attr("aria-expanded");

这篇关于如何确定引导崩溃是打开还是关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆