Jquery UI Nested Accordion with Content in top level Accordion

前端 未结 2 1476
既然无缘
既然无缘 2021-02-06 08:04

I\'m trying to create a navigation menu that contains multiple level of organization. I\'m building a nested jQuery UI Accordion that works great if all my content in the lowest

相关标签:
2条回答
  • 2021-02-06 08:44

    This should work

    <div id="faqs-container" class="accordian">
        <h3><a href="#">One</a></h3>
    
       <div class="accordian">
               I really want a list here!
            <h3><a class=href="#">A</a></h3>
            <div>
                <ul>
                    <li>list</li>
                    <li>list</li>
                    <li>list</li>
                </ul>
                </div>
            <h3><a href="#">B</a></h3>
            <div>    
                <ul>
                    <li>list</li>
                    <li>list</li>
                    <li>list</li>
                </ul>
           </div>
        </div>
        <h3><a href="#">Two</a></h3>
        <div> <-- A Wrapper -->
                 <ul>
                        <li>But They</li>
                        <li>Do Not</li>
                        <li>Work</li>
                    </ul>
             <div class="accordian">
                <h3><a href="#">A2</a></h3>
                <div>
                    <ul>
                        <li>list</li>
                        <li>list</li>
                        <li>list</li>
                    </ul>
                </div>
                <h3><a href="#">B2</a></h3>
                <div>
                    <ul>
                        <li>list</li>
                        <li>list</li>
                        <li>list</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    

    Demo: Fiddle

    For the tab Two you need to create another wrapper element and place the ul and child accordion as its children

    0 讨论(0)
  • 2021-02-06 09:01

    Check out this fiddle

    You're correct that it looks at the next element after the header, therefore you can simply wrap the content of the top-level accordion with a div, then include your sub-accordion.

    <h3><a href="#">Two</a></h3>
    
        <div>  <!-- This wrapper -->
            <ul>
                <li>But They</li>
                <li>Do Not</li>
                <li>Work</li>
            </ul>
            <div class="accordian">
                 <h3><a href="#">A2</a></h3>
    
                <div>
                    <ul>
                        <li>list</li>
                        <li>list</li>
                        <li>list</li>
                    </ul>
                </div>
                 <h3><a href="#">B2</a></h3>
    
                <div>
                    <ul>
                        <li>list</li>
                        <li>list</li>
                        <li>list</li>
                    </ul>
                </div>
            </div>
        </div>
    
    0 讨论(0)
提交回复
热议问题