I have successfully implemented bootstrap multilevel dropdowns. However, I am facing an issue where only one child is displayed at a time.
<div class="container">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Tutorials
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">HTML</a></li>
<li><a tabindex="-1" href="#">CSS</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">New dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a class="test" href="#">Size6</span></a>
<ul class="dropdown-menu">
<li><a href="#">6</a></li>
<li><a href="#">6</a></li>
<li><a href="#">6</a></li>
<li><a href="#">6</a></li>
<li><a href="#">6</a></li>
<li><a href="#">6</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a class="test" href="#">Size5</a>
<ul class="dropdown-menu">
<li><a href="#">5555555555555555555555555</a></li>
<li><a href="#">5555555555555555555555555</a></li>
<li><a href="#">55555555555555555555555</a></li>
<li><a href="#">55555555555555555555555</a></li>
<li><a href="#">55555555555555555555555555</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a class="test" href="#">Size4</span></a>
<ul class="dropdown-menu">
<li><a href="#">4444</a></li>
<li><a href="#">4444</a></li>
<li><a href="#">4444</a></li>
<li><a href="#">4444</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a class="test" href="#">Size3</a>
<ul class="dropdown-menu">
<li><a href="#">33</a></li>
<li><a href="#">33</a></li>
<li><a href="#">33</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a class="test" href="#">Size2</a>
<ul class="dropdown-menu">
<li><a href="#">22222222222222</a></li>
<li><a href="#">22222222222222</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a class="test" href="#">Size1</a>
<ul class="dropdown-menu">
<li><a href="#">111111111111111111</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<script>
$(document).ready(function() {
$('.dropdown-submenu a.test').on("click", function(e) {
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
});
</script>
The complete code example can be found here.
My current issue is that when switching from Size6 to Size5, both dropdowns are displayed simultaneously. I want to close the current submenu when transitioning between different dropdown menus. The problem can be seen in the image below: