How to determine if a bootstrap collapse is opening or closing?

user1186050 picture user1186050 · Oct 13, 2015 · Viewed 61.4k times · Source

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
}

Answer

user1186050 picture user1186050 · Oct 13, 2015

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

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