The data-toggle attributes in Twitter Bootstrap The data-toggle attributes in Twitter Bootstrap javascript javascript

The data-toggle attributes in Twitter Bootstrap


It is a Bootstrap data attribute that automatically hooks up the element to the type of widget it is. Data-* is part of the html5 spec, and data-toggle is specific to Bootstrap.

Some Examples:

data-toggle="modal"data-toggle="collapse"data-toggle="dropdown"data-toggle="tab"

Go through the Bootstrap JavaScript docs and search for data-toggle and you will see it used in the code examples.

One working example:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/><div class="dropdown">  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">    <li><a href="#">Item</a></li>  </ul></div>