简体   繁体   English

JQuery Accordion SubMenu / Nested无法正常工作

[英]JQuery Accordion SubMenu/Nested not working

I am using JQuery Accordion and it works as it should and opens and closes fine....BUT I want to add an accordion submenu and this doesn't work nor styles either. 我正在使用JQuery Accordion,它可以正常工作并打开和关闭....但我想添加一个手风琴子菜单,这也不起作用,也不是样式。

My libraries: 我的图书馆:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/start/jquery-ui.css" type="text/css" rel="Stylesheet" />

I added this test: 我添加了这个测试:

<p><a href="#">TEST MAIN MENU</a></p>
<div>

<h3><a href="#">Sub header</a></h3>
<div>sub content here</div>

</div>

and "Sub header" is not styled as a header nor it wraps up the div below it like "TEST MAIN MENU" does...

On the <head> I have this:

<script>
      $(function() {
            $( "#accordion" ).accordion({
                  active: false,
            autoHeight: false,
            collapsible: true,
            alwaysOpen: false
            });
      });

      function collapseAll() {
    $("#accordion")
        .filter(":has(.ui-state-active)")
        .accordion("activate", -1);
    $(".ui-accordion-header").blur();
}

</script>

All I need is to make "<h3><a href="#">Sub header</a></h3>" a collapsable div too. All I need is to make "<h3><a href="#">Sub header</a></h3>"一个可折叠的div。

If you want accordion within an accordion then this is your solution. 如果您想在手风琴中使用手风琴,那么这就是您的解决方案。

By the way, when you say "#accordion" in js code, jQuery will try to find an element with id="accordion" and apply the styles to it. 顺便说一句,当你在js代码中说“#acordord”时,jQuery会尝试找到一个id =“accordion”的元素并将样式应用到它。 In the html that you have currently posted you have no such element. 在您当前发布的html中,您没有这样的元素。

You can't have a submenu in an accordion. 您不能在手风琴中有子菜单。

"and "Sub header" is not styled as a header", Where is the CSS? “和”子标题“没有被设置为标题”,CSS在哪里? What do you mean not styled as a header? 你是什​​么意思没有标题?

Can you give an example of what it is you want? 你能举个例子说明你想要什么吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM