1

我有以下标记,我想使用 jQuery UI 手风琴,但它不像我在 HTML5 之前制作的典型手风琴那样呈现。我怎样才能通过使用文章/部分来获得手风琴?

<article>
    <h1>Accordion</h1>
    <div id="accordion">
        <section>
            <h1><a href="#">Aliquam tincidunt mauris eu risus.</a></h1>
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna.</p>
        </section>
        <section>
            <h1><a href="#">Integer vitae libero ac risus egestas placerat.</a></h1>
            <p>Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus.</p>
        </section>
        <section>
            <h1><a href="#">Fusce lobortis lorem at ipsum semper sagittis.</a></h1>
            <p>Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus.</p>
        </section>
    </div>
</article>

在javascript中我使用:

$(document).ready(function (){
    $('#accordion').accordion();    
});
4

2 回答 2

3

我们已经在 J​​SFiddle 中测试了以下代码...

<div id="accordion">
   <article class="std_page_content">
    <a id="#test" href="#test" class="header"><h1>Aliquam tincidunt mauris eu risus</h1></a>
    <section>
           <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna.</p>
        </section>
    <a href="#test" class="header"><h1>Integer vitae libero ac risus egestas placerat.</h1></a>
       <section>
            <p>Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus.</p>
        </section>
       <a href="#test" class="header"><h1>Fusce lobortis lorem at ipsum semper sagittis.</h1></a>
        <section>
            <p>Morbi interdum mollis sapien. Sed ac risus. Phasellus lacinia, magna a ullamcorper laoreet, lectus arcu pulvinar risus, vitae facilisis libero dolor a purus. Sed vel lacus.</p>
        </section>
   </article>
</div>

手风琴代码为 -

$("#accordion").accordion({header : "a.header", heightStyle : "content", 
   /*Allows full collapse*/collapsible: true, 
   /*collapses sections*/ active:false, 
   navigation:true
});

我们的链接是 - http://jsfiddle.net/3tGYB/2/

你可以试试这个...

于 2013-03-21T03:06:09.833 回答
2

作为旁注,您最好使用detailsandsummary元素。

于 2013-03-21T07:50:46.477 回答