lundi 20 avril 2015

Bootstrap & jQuery - Toggle Div based on Bootstrap Dropdown Menu open or close

I want to show a div when Bootstrap Dropdown opens and hide the same when dropdown closes...


FIDDLE


HTML


<ul class="dropdown" id="flatmenu">
  <li data-toggle="dropdown" aria-expanded="true"><a href="#">Dropdown<span class="caret"></span></a></li>
  <div class="dropdown-menu fm-container" role="menu" aria-labelledby="dropdownMenu">
    Dropdown Content
  </div>
</ul>


<div class="show-me">Show Me</div>

CSS


body{width:400px;margin:50px auto;}
ul,li{list-style:none;margin:0;padding:0;}
.show-me{display:none;margin-top:200px;}

jQuery


if($('#flatmenu').hasClass('open')){
    $('.show-me').show('slow');
}else{
    $('.show-me').hide('slow');
}

Aucun commentaire:

Enregistrer un commentaire