Expanding and Collapsing Elements via Data Attributes - HTML CSS Bootstrap

HTML CSS examples for Bootstrap:Accordion

Description

Expanding and Collapsing Elements via Data Attributes

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Creating Bootstrap 3 Collapsible Element via Data Attributes</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  <style type="text/css">
p{<!--from  w  w w.  j a v a2  s.  c om-->
    background: #F9F9F9;
    border: 1px solid #E1E1E8;
    margin: 10px 0;
    padding: 8px;
}
.bs-example{
  margin: 20px;
}
</style>
 </head>
 <body>
  <div>
   <!-- Trigger Button HTML -->
   <input type="button" class="btn btn-primary" data-toggle="collapse" data-target="#toggleDemo" value="Toggle Button">
   <!-- Collapsible Element HTML -->
   <div id="toggleDemo" class="collapse in">
    <p>This is a simple example of expanding and collapsing individual element via data attribute. Click on the <b>Toggle Button</b> button to see the effect.</p>
   </div>
  </div>
 </body>
</html>

Related Tutorials