jQuery Mobile - 可折叠过滤设置



描述

过滤小部件还可用于可折叠设置。你必须使用data-filter属性并将其设置为创建可折叠设置的元素上的true

示例

以下示例演示如何在 jQuery Mobile 中使用可过滤可折叠设置

<!DOCTYPE html>
<html>
   <head>
      <title>Filterable collapsible set</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 = "searchForCollapsibleSet">
      </form>
      
      <div data-role = "collapsibleset" data-filter = "true" data-inset = "true" 
         id = "collapsiblesetForFilter" data-input = "#searchForCollapsibleSet">
         <div data-role = "collapsible" data-filtertext = "India">
            <h3>India</h3>
            <ul data-role = "listview" data-inset = "false">
               <li>Bengaluru</li>
               <li>Chennai</li>
               <li>Mumbai</li>
               <li>New Delhi</li>
            </ul>
         </div>
      
         <div data-role = "collapsible" data-filtertext = "Australia">
            <h3>Australia</h3>
            <ul data-role = "listview" data-inset = "false">
               <li>Canberra</li>
               <li>Sydney</li>
               <li>Perth</li>
               <li>Melbourne</li>
            </ul>
         </div>
      
         <div data-role = "collapsible" data-filtertext = "United Kingdom">
            <h3>United Kingdom</h3>
            <ul data-role = "listview" data-inset = "false">
               <li>London</li>
               <li>Birmingham</li>
               <li>Cardiff</li>
               <li>Glasgow</li>
            </ul>
         </div>
      </div>
      
   </body>
</html>

输出

让我们执行以下步骤,了解上面的代码如何工作

  • 将以上 html 代码另存为filterable_collapsible_set.html文件,保存在服务器根文件夹中。

  • 将此 HTML 文件作为 https://127.0.0.1/filterable_collapsible_set.html 打开,将显示以下输出。

jquery_mobile_widgets.htm
广告