accordion可用在菜单的显示,先来看看效果:
先导入必要的css以及js:
<link type="text/css" href="base/ui.all.css" rel="stylesheet" /><script type="text/javascript" src="jquery-1.3.2.min.js"></script><script type="text/javascript" src="ui/ui.core.js"></script><script type="text/javascript" src="ui/ui.accordion.js"></script>
设置界面的效果:每一个选项为粗体显示区域;id为demo的div为整个accordion的容器;
<div class="demo" style="padding:10px; width:350px; height:220px;"><div id="accordion"><h3><a href="#">选项一</a></h3><div><p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integerut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sitamet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo utodio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p></div><h3><a href="#">选项二</a></h3><div><p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit ametpurus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitorvelit, faucibus interdum tellus libero ac justo. Vivamus non quam. Insuscipit faucibus urna.</p></div><h3><a href="#">选项三</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 liberoac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quislacinia 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><a href="#">选项四</a></h3><div><p>Cras dictum. Pellentesque habitant morbi tristique senectus et netuset malesuada fames ac turpis egestas. Vestibulum ante ipsum primis infaucibus orci luctus et ultrices posuere cubilia Curae; Aenean laciniamauris vel est.</p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.Class aptent taciti sociosqu ad litora torquent per conubia nostra, perinceptos himenaeos.</p></div>
</div></div>
最后的实现:
$(function(){
$("#accordion").accordion({autoHeight: false,icons: {header: "ui-icon-circle-arrow-e",headerSelected: "ui-icon-circle-arrow-s"}});});
看看特殊的一些属性:
animated
Type:
Boolean, String
Default:
‘slide’
菜单显示的动画效果;
autoHeight
Type:
Boolean
Default:
true
是否自定义高度;
icons
Type:
Object
Default:
{ ‘header’: ‘ui-icon-triangle-1-e’, ‘headerSelected’: ‘ui-icon-triangle-1-s’ }
自定义图标;