简体   繁体   中英

active state in accordion menu

I used accordion menu for my web page which is extracted from this site http://www.designchemical.com/lab/jquery-vertical-accordion-menu-plugin/examples/ .If i click the main menu corresponding sub menu opens. If i click the submenu it redirected to the linked page. But the menu is not in opened state in that page. This is my problem. How can i correct that?

The internal script that i have used is

<script type="text/javascript">
$(document).ready(function($){
    $('#accordion-3').dcAccordion({
        eventType: 'click',
        autoClose: false,
        saveState: false,
        disableLink: false,
        showCount: false,
        speed: 'slow'
    });
});
</script>

Save the current state in a cookie

setCookie('state',$( "#accordion-3" ).accordion('option','active'));

And on the other page after redirection

$('#accordion-3').dcAccordion({
        active:getCookie('state'), /****activating the current state***/
        eventType: 'click',
        autoClose: false,
        disableLink: false,
        showCount: false,
        speed: 'slow'
    });

/**cookie functionalities***/
function deleteCookie(name) {
        setCookie(name,"",-1);
    }
    function setCookie(name,value,days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
        }
        else expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
    }
    function getCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM