4

私は動作する単純なjQueryアコーディオンを持っています...ほぼ完璧に:)

デモからわかるように、現在、「チーム」ページにいるので、ナビゲーションを「開いています」。

「AboutUs」をクリックすると、要素が完全に閉じます。デモからわかるように、閉じます、すぐに再度開きます。これは、CSSの27行目のコードが原因で発生していると思います。

これが私のデモです:http ://jsfiddle.net/URYzK/5/

これが私のJavaScriptです:

jQuery(function($) {

    $('#accordion > li > a').click(function (e) {
        if ($(this).next('ul').length == 0) {
            // link is for navigation, do not set up accordion here
            return;
        }

        // link is for accordion pane

        //remove all the "Over" class, so that the arrow reset to default
        $('#accordion > li > a').not(this).each(function () {
            if ($(this).attr('rel')!='') {
                $(this).removeClass($(this).attr('rel') + 'Over');
            }

            $(this).siblings('ul').slideUp("slow");
        });

        //showhide the selected submenu
        $(this).siblings('ul').slideToggle("slow");

        //addremove Over class, so that the arrow pointing downup
        $(this).toggleClass($(this).attr('rel') + 'Over');
        e.preventDefault();
    });

});

ここで助けてくれてありがとう。

4

1 に答える 1

0

CSS を完全に削除しますdisplay:none。これにより、必要な動作が作成されると思います。あなたは子供たちを に設定し、強制的に にしようとしていました。#accordian ul.childrenuldisplay:none.childrenuldisplay:block

jsFiddle も更新しました。

于 2013-03-05T15:11:05.700 に答える