Hey all!
I had to change plans on my accordion and shifted to one that stores its collapse/open state with a cookie. It works great as you can see in the example I put up here.
The JS code goes like this:
<script>
$(document).ready(function () {
var checkCookie = $.cookie("nav-item");
if (checkCookie != "") {
$('#nav > li > a:eq('+checkCookie+')').addClass('active').next().show();
$('#nav > li > ul > li a:eq('+checkCookie+')').addClass('active').next().show();
}
$('#nav > li > a').click(function(){
var navIndex = $('#nav > li > a').index(this);
$.cookie("nav-item", navIndex);
$('#nav li ul').slideUp();
if ($(this).next().is(":visible")){
$(this).next().slideUp();
} else {
$(this).next().slideToggle();
}
$('#nav li a').removeClass('active');
$(this).addClass('active');
});
});
</script>
Now I would like to achieve 2 things:
1: The last link clicked changes its style AND saves it. So when i visit a link in the submenu not only the accordion stays open, the link looks different too.
2: When I click the logo above the menu (see my example) I’d like to have the accordion all collapsed again. Like when i first visit the website.