Submit your widget

Simple JQuery Accordion Collapsing menu

Created 10 years ago   Views 86548   downloads 20090    Author n/a
Simple JQuery Accordion Collapsing menu
View DemoDownload 18.1 KB
258
Share |

This is a simple Accordion collapsing menu done in JQuery. Links with subitems under them will expand the submenu when clicked. Items that don't have subitems are normal links.. The menu initialises with the first submenu expanded.

Javascript

 

     function initMenu() {
    $('#menu ul').hide();
    $('#menu ul:first').show();
    $('#menu li a').click(
    function() {
    var checkElement = $(this).next();
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
    return false;
    }
   if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
   $('#menu ul:visible').slideUp('normal');
   checkElement.slideDown('normal');
   return false;
   }
   }
   );
   }
   $(document).ready(function() {initMenu();});