Javascript 引导手风琴在另一个打开时隐藏

Javascript 引导手风琴在另一个打开时隐藏,javascript,jquery,accordion,Javascript,Jquery,Accordion,我试着做手风琴时,一个是开放的,而另一个将关闭。 这是我的js: $(".uv-accordinaton-list").on( "click", function() { $(this).next().slideToggle(200); $(this).find(">:first-child"); if($(this).find(">:first-child").text() == "+") { $(this).find(">:first-chi

我试着做手风琴时,一个是开放的,而另一个将关闭。 这是我的js:

 $(".uv-accordinaton-list").on( "click", function() {
   $(this).next().slideToggle(200);
   $(this).find(">:first-child");
   if($(this).find(">:first-child").text() == "+") {
      $(this).find(">:first-child").text("-");
      $(this).find("h2").addClass("hilighted");
   } else {
   $(this).find(">:first-child").text("+");
   $(this).find("h2").removeClass("hilighted");
 }
实时链接是:


提前谢谢

也许你可以试试这个

  $(".uv-accordinaton-list").on( "click", function() {
    $(".uv-accordinaton-list>:first-child").text("+");
    $(".uv-accordinaton-list h2").removeClass("hilighted");
    $(".uv-accordition-detail").slideUp();
    if($(this).find(">:first-child").text() == "+") {
     $(this).next().slideToggle(200);
       $(this).find(">:first-child").text("-");
      $(this).find("h2").addClass("hilighted");
    }
  });
功能切换图标(e){
美元(e.target)
.prev(“.面板标题”)
.find(“.more-less”)
.toggleClass('glyphicon-plus-glyphicon-减号');
}
$('.panel group').on('hidden.bs.collapse',toggleIcon);
$('.panel group').on('show.bs.collapse',toggleIcon)
/*******************************
*手风琴与切换图标
*如果在“折叠”之后添加“in”,则无法正常工作。
*******************************/
.小组小组.小组{
边界半径:0;
盒影:无;
边框颜色:#EEEEEE;
}
.panel默认值>.panel标题{
填充:0;
边界半径:0;
颜色:#212121;
背景色:#FAFAFA;
边框颜色:#EEEEEE;
}
.小组标题{
字体大小:14px;
}
.小组标题>a{
显示:块;
填充:15px;
文字装饰:无;
}
.更多更少{
浮动:对;
颜色:#212121;
}
.panel默认值>.panel heading+.panel collapse>.panel body{
边框顶部颜色:#EEEEEE;
}
/*----v可以被删除v-----*/
身体{
背景色:#26a69a;
}
.演示{
填充顶部:60px;
垫底:110px;
}
.演示页脚{
位置:固定;
底部:0;
宽度:100%;
填充:15px;
背景色:#212121;
文本对齐:居中;
}
.demo页脚>a{
文字装饰:无;
字体大小:粗体;
字体大小:14px;
颜色:#fff;
}

动物保护协会的陈词滥调,埃尼姆·埃乌斯莫德的高寿命accusamus terry richardson广告鱿鱼。3狼月亮奥特餐厅,非丘比特滑板多洛早午餐。食品车奎奴亚藜。早午餐3狼月亮临时,圣塔阿利夸放了一只鸟在上面鱿鱼单一来源咖啡NullaAssumenda shoreditch等Nihil anim keffiyeh helvetica,工艺啤酒工人wes anderson cred Nesciut sapiente ea proident。纯素食主义者,屠夫副洛莫。紧身裤从工艺啤酒场到餐桌,生料牛仔布美学合成物,你可能还没听说过accusamus labore可持续VHS。
动物保护协会的陈词滥调,埃尼姆·埃乌斯莫德的高寿命accusamus terry richardson广告鱿鱼。3狼月亮奥特餐厅,非丘比特滑板多洛早午餐。食品车奎奴亚藜。早午餐3狼月亮临时,圣塔阿利夸放了一只鸟在上面鱿鱼单一来源咖啡NullaAssumenda shoreditch等Nihil anim keffiyeh helvetica,工艺啤酒工人wes anderson cred Nesciut sapiente ea proident。纯素食主义者,屠夫副洛莫。紧身裤从工艺啤酒场到餐桌,生料牛仔布美学合成物,你可能还没听说过accusamus labore可持续VHS。
动物保护协会的陈词滥调,埃尼姆·埃乌斯莫德的高寿命accusamus terry richardson广告鱿鱼。3狼月亮奥特餐厅,非丘比特滑板多洛早午餐。食品车奎奴亚藜。早午餐3狼月亮临时,圣塔阿利夸放了一只鸟在上面鱿鱼单一来源咖啡NullaAssumenda shoreditch等Nihil anim keffiyeh helvetica,工艺啤酒工人wes anderson cred Nesciut sapiente ea proident。纯素食主义者,屠夫副洛莫。紧身裤从工艺啤酒场到餐桌,生料牛仔布美学合成物,你可能还没听说过accusamus labore可持续VHS。
检查以下代码:

$(".uv-accordinaton-list") . on("click", function() {
    $(this).closest("ul").find(".uv-accordition-detail").each(function() {
        if ($(this).css("display") == 'block') {
            $(this).slideUp(200);
            $(this).closest("li").find("h2").removeClass("hilighted");
            $(this).closest("li").find(".uv-right-arrow").text("+");
            return false;
        }
    });
    $(this).next().slideToggle(200);
    $(this).find(">:first-child");
    if ($(this).find(">:first-child").text() == "+") {
        $(this).find(">:first-child").text("-");
        $(this).find("h2").addClass("hilighted");
    } else {
        $(this).find(">:first-child").text("+");
        $(this).find("h2").removeClass("hilighted");
    }
});

工作示例:

其可能的重复项不相同。我在js的一个面板上使用加减。欢迎使用stackoverflow。除了提供代码,请考虑添加一个你改变了什么以及它为什么工作的概要。