Bootstrap Tutorial - Handle Collapsible closed event








The following code shows how to handle Collapsible closed event.

Example

<!--   w  w  w . j a v a  2 s . c  om-->

<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of Twitter Bootstrap 3 Collapse Events</title>
<link rel="stylesheet"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
<script type="text/javascript"
  src="http://code.jquery.com/jquery.min.js"></script>
<script
  src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $('#myCollapsible').on('hidden.bs.collapse', function(){
    console.log('Collapsible element has been completely closed.');
  });
});
</script>
<style type="text/css">
p {
  background: #F9F9F9;
  border: 1px solid #E1E1E8;
  margin: 10px 0;
  padding: 8px;
}

.bs-example {
  margin: 20px;
}
</style>
</head>
<body>
  <div class="bs-example">
    <input type="button" class="btn btn-primary" data-toggle="collapse"
      data-target="#myCollapsible" value="Toggle Button">
    <div id="myCollapsible" class="collapse in">
      <p>
        If you click on the <b>Toggle
          Button</b> button you will see an alert message when the sliding
        transition of collapsible element is fully completed.
      </p>
    </div>
  </div>
</body>
</html>

Click to view the demo