I have two questions for SO.
- when an element is pressed, it will show it and hide all other elements.
- foldable responsive panel like navbar
My jsFiddle demo first: http://jsfiddle.net/JpJqD/1/
I am working on a collapsible sidebar menu.
As you can see in the demo; when I click articles
, I need to collapse (hide) others. Then, if you click users
, articles
and other items that have a sublevel, you should collapse (hide). Therefore, there should always be one open menu.
I tried with collapse
from a Bootstrap document, but I could not with the following codes:
$('#sidebar a').on('click', function () { $(this).closest('div').find('.collapse').collapse('hide'); $(this).collapse('show'); });
I can do this with accordion
, but I don't want it to call the required panel
class for all elements.
By the way, I want to make a responsive sidebar, like the navbar
menu for mobile devices and tablets? I used as in Bootstrap doc, but didn't work.
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
source share