The following code shows how to call Collapse Methods in Javascript.
<!DOCTYPE html>
<html lang="en">
<head>
<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(){<!--from w w w .java 2s . c o m-->
$(".toggle-false").click(function(){
$("#myCollapsible").collapse({
toggle: false
});
});
$(".show-btn").click(function(){
$("#myCollapsible").collapse('show');
});
$(".hide-btn").click(function(){
$("#myCollapsible").collapse('hide');
});
$(".toggle-btn").click(function(){
$("#myCollapsible").collapse('toggle');
});
});
</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">
<!-- Trigger Button HTML -->
<input type="button" class="btn btn-primary toggle-false"
value="Toggle False"> <input type="button"
class="btn btn-primary show-btn" value="Show Button"> <input
type="button" class="btn btn-primary hide-btn" value="Hide Button">
<input type="button" class="btn btn-primary toggle-btn"
value="Toggle Button">
<!-- Collapsible Element HTML -->
<div id="myCollapsible">
<p>This is an example of twitter bootstrap collapse methods.
Click on the buttons to see how it works.</p>
</div>
</div>
</body>
</html>