Search code examples
jqueryjquery-ui-accordion

jquery - simple accordion


I need is, if tab will click, open tab should close sample is here

$("#accordion > li > div").click(function () {
      $('.active').not(this).removeClass('active');

      $(this).toggleClass('active');
      if (false == $(this).next().is(':visible')) {
                  $('#accordion > ul').slideUp(300);
                }
                $(this).next().slideToggle(300);
              });

              var animationIsOff = $.fx.off;
              $.fx.off = true;
              $('#accordion > li > div:eq(0)').click()
              $.fx.off = animationIsOff;

Solution

  • Change this line:

    $('.active').not(this).removeClass('active');
    

    to:

    $('.active').not(this).removeClass('active').next().hide(300);
    

    Fiddle: http://jsfiddle.net/tyeKJ/10/