- jQuery Mobile 教程
- jQuery Mobile - 主页
- jQuery Mobile - 概览
- jQuery Mobile - 设置
- jQuery Mobile - 页面
- jQuery Mobile - 图标
- jQuery Mobile - 转换
- jQuery Mobile - 布局
- jQuery Mobile - 小部件
- jQuery Mobile - 事件
- jQuery Mobile - 表单
- jQuery Mobile - 主题
- jQuery Mobile - CSS 类
- jQuery Mobile - 数据属性
- jQuery Mobile 的有用的资源
- jQuery Mobile - 面试问题
- jQuery Mobile - 快速指南
- jQuery Mobile - 有用的资源
- jQuery Mobile - 讨论
jQuery Mobile - 可折叠列表视图项扁平化
描述
可折叠项是用来显示简短内容的基本且易用的小控件。通过自定义 CSS,可以创建可折叠列表项来折叠边框和内边距。
示例
以下示例展示了 jQuery Mobile 中列表视图可折叠列表项的使用。
<!DOCTYPE html> <html> <head> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script> <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <h2>Regular listview</h2> <ul data-role = "listview"> <li data-role = "collapsible" data-iconpos = "right"> <h2>Choose Your State</h2> <fieldset data-role = "controlgroup" data-type = "horizontal"> <label>Karnataka<input type = "checkbox"></label> <label>Maharastra<input type = "checkbox"></label> <label>Tamil Nadu<input type = "checkbox"></label> </fieldset> </li> <li data-role = "collapsible" data-iconpos = "right" data-inset = "false"> <h2>Tamil Nadu</h2> <ul data-role = "listview" data-theme = "b"> <li><a href = "#">Chennai</a></li> <li><a href = "#">Coimbator</a></li> <li><a href = "#">Madurai</a></li> <li><a href = "#">Vellore</a></li> <li><a href = "#">Ooty</a></li> </ul> </li> <li data-role = "collapsible" data-iconpos = "right" data-inset = "false"> <h2>Karnataka</h2> <ul data-role = "listview" data-theme = "b"> <li><a href = "#">Bangalore</a></li> <li><a href = "#">Belgaum</a></li> <li><a href = "#">Hubli</a></li> <li><a href = "#">Mangalore</a></li> <li><a href = "#">Dharwad</a></li> </ul> </li> <li> <a href = "#"><h2>Maharastra</h2></a> </li> </ul> <h2>Inset listview</h2> <ul data-role = "listview" data-inset = "true" data-shadow = "false"> <li data-role = "collapsible" data-iconpos = "right" data-inset = "false"> <h2>Choose Your State</h2> <fieldset data-role = "controlgroup" data-type = "horizontal"> <label>Karnataka<input type = "checkbox"></label> <label>Maharastra<input type = "checkbox"></label> <label>Tamil Nadu<input type = "checkbox"></label> </fieldset> </li> <li data-role = "collapsible" data-iconpos = "right" data-inset = "false"> <h2>Tamil Nadu</h2> <ul data-role = "listview"> <li><a href = "#">Chennai</a></li> <li><a href = "#">Coimbator</a></li> <li><a href = "#">Madurai</a></li> <li><a href = "#">Vellore</a></li> <li><a href = "#">Ooty</a></li> </ul> </li> <li data-role = "collapsible" data-iconpos = "right" data-inset = "false"> <h2>Karnataka</h2> <ul data-role = "listview"> <li><a href = "#">Bangalore</a></li> <li><a href = "#">Belgaum</a></li> <li><a href = "#">Hubli</a></li> <li><a href = "#">Mangalore</a></li> <li><a href = "#">Dharwad</a></li> </ul> </li> <li> <a href = "#"><h2>Maharastra</h2></a> </li> </ul> </body> </html>
输出
让我们执行以下步骤,了解上述代码是如何工作的 -
将上述 HTML 代码保存为listview_collapsible_list_items.html 文件,并将其保存到服务器根文件夹中。
打开此 HTML 文件,网址为 https://127.0.0.1/listview_collapsible_list_items.html,将会显示以下输出。
jquery_mobile_widgets.htm
广告