筛选器可折叠集合和可折叠子项
描述
过滤器小部件也可用于可折叠集合和可折叠子项。
示例
以下示例演示了在 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.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script> <script src = "https://code.jquery.com/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 文件。
将此 HTML 文件打开为 http://localhost/filterable_collapsible_set_children.html,将显示以下输出。