I came across a nested JQuery accordion code that works perfectly, but there's a major issue. When I click on a menu or submenu in my sidebar (a link that redirects to a different URL), the site fails to remember which menu or submenu should be shown or hidden after a refresh (the default state is hiding all except the 1st level ul). Is there any way to make my menu remember its last state before a refresh? Thank you for your assistance.
HTML:
<ul>
<li>
<a href="foo1.php">level 2</a>
<ul>
<li><a href="foo2.php">a</a></li>
<li><a href="foo3.php">b</a></li>
</ul>
</li>
<li>
<a href="foo4.php">level 2</a></li>
<ul>
<li>
<a href="foo5.php">level 3</a>
<ul>
<li><a href="foo6.php">c</a></li>
<li><a href="foo7.php">d</a></li>
</ul>
</li>
<li><a href="foo8.php">e</a></li>
<li><a href="foo9.php">f</a></li>
</ul>
</li>
</ul>
Jquery:
$('ul li ul').hide();
$('ul li').click(function(ev) {
$(this).find('>ul').slideToggle();
ev.stopPropagation();
});
Real HTML:
<ul class="arrows_list1-1">
<h3>Naše produkty</h3>
<div class="menu-produkty-container">
<ul id="menu-produkty" class="menu">
[Content has been truncated here for brevity]
</ul>
</div>
</ul>
Real Jquery:
$('.arrows_list1-1 li ul').hide();
$('.arrows_list1-1 li').click(function(ev) {
$(this).find('>ul').slideToggle();
ev.stopPropagation();
});