JQuery 手风琴子菜单/嵌套不起作用

JQuery Accordion SubMenu/Nested not working

本文关键字:嵌套 不起作用 菜单 琴子 JQuery      更新时间:2023-09-26

我正在使用JQuery手风琴,它可以正常工作,并且可以正常打开和关闭....但是我想添加一个手风琴子菜单,这不起作用,样式也不起作用.

我的图书馆:

<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" />

我添加了这个测试:

<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>"也是一个可折叠的div。

如果你想在手风琴中手风琴,那么这就是你的解决方案.

顺便说一下,当你在js代码中说"#accordion"时,jQuery会尝试找到一个id="accordion"的元素,并对其应用样式。在您当前发布的html中,您没有这样的元素。

手风琴中不能有子菜单。

">

和"子标题"没有样式为标题",CSS 在哪里?你的意思不是标题的样式?

你能举个例子来说明你想要什么吗?