I have this code that leaves the menu active and expands.
<li class="menu-item">
<a href="#" class"active">
<span>Posts</span>
</a>
<ul class="sub-menu">
<li><a href="#">Ver Posts</a></li>
<li><a href="#">Novo Post</a></li>
</ul>
</li>
$(".menu-item > a").click(function(){
$(".sub-menu").slideUp();
if(!$(this).next().is(":visible")) {
$(this).next().slideDown();
}
$('.active').removeClass('active');
$(this).addClass('active');
localStorage.setItem("activeDiv", $(this).index('.menu-item > a'));
});
var activeIndex = localStorage.getItem("activeDiv");
if (activeIndex) {
$('.menu-item').removeClass('active').eq(activeIndex).addClass('active');
}
How do I do when I click on the "View Posts or New Post" submenu to continue open after page refresh?