Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery Accordion Menu Help

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #28641

    Reference: http://stuff.fiveeightfive.com/WMU_mock … xy_hg.html

    I’m trying to add another level to the menu on the left side of the page. For instance, if someone clicks ‘Food Pantry’ it expands and shows all of Food Pantry’s subcategories, but I would like to take it further. So if someone clicks on a subcategory of Food Pantry it would expand to show those sub subcategories and so on.

    Here’s the jQuery:

    Code:
    function initMenus() {
    $(‘ul.menu ul’).hide();
    $.each($(‘ul.menu’), function(){
    $(‘#’ + this.id + ‘.expandfirst ul:first’).show();
    });
    $(‘ul.menu li a’).click(
    function() {
    var checkElement = $(this).next();
    var parent = this.parentNode.parentNode.id;

    if($(‘#’ + parent).hasClass(‘noaccordion’)) {
    $(this).next().slideToggle(‘normal’);
    return false;
    }
    if((checkElement.is(‘ul’)) && (checkElement.is(‘:visible’))) {
    if($(‘#’ + parent).hasClass(‘collapsible’)) {
    $(‘#’ + parent + ‘ ul:visible’).slideUp(‘normal’);
    }
    return false;
    }
    if((checkElement.is(‘ul’)) && (!checkElement.is(‘:visible’))) {
    $(‘#’ + parent + ‘ ul:visible’).slideUp(‘normal’);
    checkElement.slideDown(‘normal’);
    return false;
    }
    }
    );
    }
    $(document).ready(function() {initMenus();});

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.