簡體   English   中英

jQuery Accordion的簡單問題

[英]Simple issue with jQuery Accordion

我有一個簡單的jQuery手風琴,可以工作... 幾乎完美:)

正如您在演示中看到的那樣,我現在在“團隊”頁面中將導航設置為“打開”。

當我點擊“關於我們”時,它可以完全關閉元素。 正如您從演示中看到的那樣,它會將其關閉, 隨后會快速重新打開它。 我想這是因為我的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();
    });

});

非常感謝您的幫助。

刪除display:none#accordian ul和刪除.children完全CSS。 我相信這會創造出你想要的行為。 你正在設置孩子ul display:none ,然后試圖強制.children ,這是一個uldisplay:block稍后display:block ,這就是為什么他們在戰斗。

更新了你的jsFiddle。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM