1

I am not good with jQuery. I found the following accordion panel script. This script hides all panels on load and open one when I click on it. However, I want to have all panels open on load and only click the one I want to hide. don't want to hide all when I click on it.

// accordion
    $('.accordion h5').click(function () {
        $('.accordion h5').removeClass('open');
     // close all slides
        $('.accordion ul ul').slideUp('normal');
        if ($(this).next().is(':hidden') == true) {
            $(this).addClass('open');
            $(this).next().slideDown('normal');
        }
    });
    $('.accordion h5').mouseover(function () {
        $(this).addClass('hover');
    }).mouseout(function () {
        $(this).removeClass('hover');
    });
    $('.accordion ul ul').show();
4

1 に答える 1

0

以下はあなたが望む振る舞いを与えるはずです。

 $('.accordion h5').click(function () {
        $(this).toggleClass('open').next().slideToggle(); 
 }).hover(function(){
       $(this).toggleClass('hover');    
 });

これを変更する必要がある場合は、マークアップを提供します

于 2012-10-29T18:26:58.587 に答える