Reputation: 17393
I'm using this Jquery code to open/close my submenus :
(function() {
$('#MainMenu > li').click(function(e) {
e.stopPropagation();
var $el = $('ul',this);
$('#MainMenu > li > ul').not($el).slideUp();
$el.stop(true, true).slideToggle(400);
});
$('#MainMenu > li > ul > li').click(function(e) {
e.stopImmediatePropagation();
});
})();
<ul class="nav nav-pills nav-stacked nav-arrow" id="MainMenu">
.
.
.
but at the first time (when page is loaded), all submenus are open. I want all submenus be closed until user click on menu.
Upvotes: 1
Views: 39
Reputation: 20750
Use this following CSS
to keep all submenus hidden initially.
#MainMenu > li > ul {
display: none;
}
If you want to use jQuery to hide then use following line on page load.
$('#MainMenu > li > ul').hide();
Upvotes: 2