It appears that crash () is triggered for the first time using "show" no matter what. A simple solution is to check if the .inbox is displayed, and if it does, to minimize the crash (βhideβ). We can get the state of an element by checking if the class "in" -.collapse = element hidden, .collapse.in = element is shown
$("button.resize").click(function(){ var isExpanded = !$("div.box").hasClass("expanded"); $("div.box").toggleClass("expanded", isExpanded); if ($("div.inbox").hasClass("in")) { $("div.inbox").collapse('hide'); } });
source share