Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jqueryaccordio的简单问题_Javascript_Jquery_Css_Accordion - Fatal编程技术网

Javascript jqueryaccordio的简单问题

Javascript jqueryaccordio的简单问题,javascript,jquery,css,accordion,Javascript,Jquery,Css,Accordion,我有一个简单的jQuery手风琴,它可以工作。。。几乎完美:) 正如您从演示中看到的,我目前在“团队”页面中,导航处于“打开”状态 当我单击“关于我们”时,是否可能完全关闭元素。正如您从演示中看到的,它会关闭它,但会快速重新打开它。我想这是因为CSS第27行的代码 这是我的演示: 以下是我的JavaScript: jQuery(function($) { $('#accordion > li > a').click(function (e) { if ($(

我有一个简单的jQuery手风琴,它可以工作。。。几乎完美:)

正如您从演示中看到的,我目前在“团队”页面中,导航处于“打开”状态

当我单击“关于我们”时,是否可能完全关闭元素。正如您从演示中看到的,它会关闭它,会快速重新打开它。我想这是因为CSS第27行的代码

这是我的演示:

以下是我的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();
    });

});

非常感谢您在此提供的帮助。

#accordian ul
中删除
显示:无
,并完全删除
.children
CSS。我相信这会创造出你想要的行为。您将儿童
ul
设置为
display:none
,然后试图强制
.children
,这是一个
ul
,稍后将其设置为
display:block
,这就是他们打架的原因


还更新了您的JSFIDLE。

很酷-现在将对此进行尝试-感谢您的回复:)