I would like to do dropdown menus with simple interactions. One of the dropdown should be open by default. When we click on another div it should open and old opened dropdown should close it's self automatically. I tried it doesn't work fine. Can you guys please help? I have attach my code below.
$(document).ready(function() {
$(".nb-filter-hd a").on("click", function(e) {
e.PreventDefault;
var grabID = $(this).attr("href");
$('div' + grabID).toggleClass("hide");
$("div").not('div' + grabID).addClass("hide");
});
});
.nb-filter-hd {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
align-content: stretch;
}
.hide {
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section class="nb-filter row-fluid full-width">
<div class="container-fluid">
<ul class="nb-filter-hd">
<li> <a href="#industries"> Industries </a> </li>
<li> <a href="#type"> Type </a> </li>
<li> <a href="#platforms"> Platforms </a> </li>
</ul>
<div class="nb-industries-list row-fluid" id="industries">
one
</div>
<div class="nb-industries-list hide row-fluid" id="type">
two
</div>
<div class="nb-industries-list hide row-fluid" id="platforms">
three
</div>
</div>
</section>