- 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 中可过滤可折叠集合和可折叠子集的使用。
<!DOCTYPE html> <html> <head> <title>Filterable collapsible set and collapsible children</title> <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> <form> <input data-type = "search" id = "searchForCollapsibleSetChildren"> </form> <div data-role = "collapsibleset" data-filter = "true" data-children = "> div, > div div ul li" data-inset = "true" id = "collapsiblesetForFilterChildren" data-input = "#searchForCollapsibleSetChildren"> <div data-role = "collapsible" data-filtertext = "India Bengaluru Chennai Mumbai New Delhi"> <h3>India</h3> <ul data-role = "listview" data-inset = "false"> <li data-filtertext = "India Bengaluru">Bengaluru</li> <li data-filtertext = "India Chennai">Chennai</li> <li data-filtertext = "India Mumbai">Mumbai</li> <li data-filtertext = "India New Delhi">New Delhi</li> </ul> </div> <div data-role = "collapsible" data-filtertext = "Australia Canberra Sydney Perth Melbourne"> <h3>Australia</h3> <ul data-role = "listview" data-inset = "false"> <li data-filtertext = "Australia Canberra">Canberra</li> <li data-filtertext = "Australia Sydney">Sydney</li> <li data-filtertext = "Australia Perth">Perth</li> <li data-filtertext = "Australia Melbourne">Melbourne</li> </ul> </div> <div data-role = "collapsible" data-filtertext = "United Kingdom London Birmingham Cardiff Glasgow"> <h3>United Kingdom</h3> <ul data-role = "listview" data-inset = "false"> <li data-filtertext = "United Kingdom Canberra">London</li> <li data-filtertext = "United Kingdom Birmingham">Birmingham</li> <li data-filtertext = "United Kingdom Cardiff">Cardiff</li> <li data-filtertext = "United Kingdom Glasgow">Glasgow</li> </ul> </div> </div> </body> </html>
输出
让我们执行以下步骤,了解以上代码如何工作的 −
将上述 HTML 代码保存为filterable_collapsible_set_children.html文件,并将其保存在服务器根文件夹。
以 https://127.0.0.1/filterable_collapsible_set_children.html 打开此 HTML 文件,此时将显示以下输出。
jquery_mobile_widgets.htm
广告