开发者

JQuery Accordion Different Icon in Each Header

开发者 https://www.devze.com 2023-02-22 21:09 出处:网络
I am trying to create a Outlook style accordion for my page.The problem I am running into is finding out how to set a different icons for each header. Ex) Mail Icon by the Mail header, Contact Icon by

I am trying to create a Outlook style accordion for my page. The problem I am running into is finding out how to set a different icons for each header. Ex) Mail Icon by the Mail header, Contact Icon by t开发者_JAVA技巧he Contact Header. Any help would be greatly appreciated.


This is easy to do, with just a little CSS.

Demo

HTML

<div id="accordion"> 
    <h3 class="s1"><a href="#">Section 1</a></h3> 
    <div> 
        <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p> 
    </div> 
    <h3 class="s2"><a href="#">Section 2</a></h3> 
    <div> 
        <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p> 
    </div> 
    <h3 class="s3"><a href="#">Section 3</a></h3> 
    <div> 
        <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p> 
        <ul> 
            <li>List item one</li> 
            <li>List item two</li> 
            <li>List item three</li> 
        </ul> 
    </div> 
    <h3 class="s4"><a href="#">Section 4</a></h3> 
    <div> 
        <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p> 
    </div> 
</div> 

CSS

.ui-accordion-header.s1 .ui-icon {
    background: url(http://p.yusukekamiyamane.com/icons/search/fugue/icons/table-join.png);
}
.ui-accordion-header.s2 .ui-icon {
    background: url(http://p.yusukekamiyamane.com/icons/search/fugue/icons/home-medium.png);
}
.ui-accordion-header.s3 .ui-icon {
    background: url(http://p.yusukekamiyamane.com/icons/search/fugue/icons/store-medium.png);
}
.ui-accordion-header.s4 .ui-icon {
    background: url(http://p.yusukekamiyamane.com/icons/search/fugue/icons/balloon-facebook-left.png);
}

JavaScript

$(function() {
    $( "#accordion" ).accordion(); 
});
0

精彩评论

暂无评论...
验证码 换一张
取 消