Jquery手风琴不崩溃

Jquery accordion not collapsing

本文关键字:崩溃 手风琴 Jquery      更新时间:2023-09-26

所以我忙于为我的客户使用 Jquery 手风琴创建时事通讯存档.每个月本质上都是一个手风琴(所以月份本身是可扩展和可折叠的),每篇文章也是如此。我的第一个月(一月)工作正常,但由于某种原因,其他月份都没有按预期工作。其他"月"可以扩展和折叠,但不能折叠它们的文章。我曾无数次尝试修改Javascript,但无济于事。

这是测试站点的链接:http://promisedev.co.za/eam/gt/

如果有人有任何建议或建议,将不胜感激!

我认为问题出在您的jquery.akordeon.js文件上。 您可以删除此文件并使用此 JQuery 代码。我编辑了你的代码,你可以使用它:

jsFiddle 在这里

$(document).ready(function(){
//Hide the tooglebox when page load
$(".togglebox").hide();
$(".togglebox:first").show();
    $(".akordeon-item-head").next(".akordeon-item-body").hide();
//slide up and down when click over heading 2
$("h1").click(function(){
// slide toggle effect set to slow you can set it to fast too.
$(this).next(".togglebox").slideToggle("slow");
return true;
});
    /* here is the new Codes*/
    $(".akordeon-item-head").click(function(){
        $(this).next(".akordeon-item-body").slideToggle();
    });   
});
您所

要做的就是删除内联样式,例如height: 154pxheight: 0,并在本地/外部css中设置高度:

<style>
    .akordeon-item-body { height: 154px; }
</style>

我不得不在某个网站上使用手风琴机制,最后我自己编码

小提琴测试用例<这里>

>

重要的部分是存储最后滑动的元素

$("#commonAncestor").on('click', function (e) {
    var $me = $(this),
        $clicked = $(e.target).closest('.clickableArea', this),
        $lastClicked = $me.data('active') || $([]),
        ...
});