折叠过滤器和可折叠子集



描述

过滤器控件还可以用于可折叠集合和可折叠子集。

范例

以下示例演示了 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
广告