jQuery UI Accordion 折叠菜单
jQuery UI Accordion 插件用于创建折叠菜单
它通常与嵌套的列表、定义列表或嵌套的 div 一起使用
选项用于指定结构、激活的元素和定制的动画
jQuery UI Accordion 是 jQuery UI 的一部分
目前版本是 1.12.1
效果图示
官网
https://jqueryui.com/accordion/
想要了解更多有关 Accordion 的细节 ? 可以访问我们的 jQuery UI Accordion API 文档
引入 jQuery UI CSS 样式表
<link rel="stylesheet" href="https://cdn.staticfile.org/jqueryui/1.12.1/themes/smoothness/jquery-ui.min.css" />
引入 JavaScript 脚本文件
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script> <script src="https://cdn.staticfile.org/jqueryui/1.12.1/jquery-ui.min.js"></script>
HTML 代码
<div id="accordion"> <h3>Section 1</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>Section 2</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>Section 3</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>Section 4</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>
JavaScript 代码
$( function() { $( "#accordion" ).accordion(); } );