0

サイドバーのナビゲーションに jQuery アコーディオンを使用しています。現在、私は 2 つのリンクを持っていますが、どちらもその下に「子」があります。

これが私のjsFiddleです:http://jsfiddle.net/6Eh8C/

[About Us] をクリックすると、ギャラリーが閉じます。これは起こるべきではありません。ギャラリーは、[ギャラリー] をクリックしたときにのみ閉じる必要があります。

これを修正するにはどうすればよいですか?

これが私のjQueryです:

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();
        });     

        $('.slides_item').children('div').css('background','#ededed')

    });

ポインタをありがとう:-)

4

1 に答える 1

0

1行削除したいだけだと思います:

$('#accordion > li > a').not(this).each(function () {
    if ($(this).attr('rel')!='') {
        $(this).removeClass($(this).attr('rel') + 'Over');
    }

    // Remove this line, you don't want to slide up other uls.
    // $(this).siblings('ul').slideUp("slow");
});

例: http://jsfiddle.net/6Eh8C/1/

于 2013-03-17T18:54:16.813 に答える