jQuery Mobile - Listview 列表视图自动分隔链接栏

描述

链接栏扩展包含在自动分割器链接栏列表视图中。 它添加了一个固定在屏幕右侧的栏,这有助于非常轻松地导航到列表视图的特定部分。


示例

以下示例演示了在 jQuery Mobile 中使用 Listview Autodivider Linkbar。

<!DOCTYPE html>
<html>
   <head>
      <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">
      <link rel = "stylesheet" 
         href = " http://demos.jquerymobile.com/1.4.5/listview-autodividers-linkbar/autodividers-linkbar.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/jquery-1.11.3.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
      <script src = "http://demos.jquerymobile.com/1.4.5/listview-autodividers-linkbar/autodividers-linkbar.js"></script>
   </head>
   
   <body>
      <div data-role = "page" id = "demo-page">
         <div data-role  =  "header">
            <h2>Listview Autodivider Linkbar</h2>
            <a href = "#" class = "jqm-search-link ui-shadow ui-btn ui-btn-icon-notext 
               ui-corner-all ui-icon-search ui-nodisc-icon ui-alt-icon 
               ui-btn-right">Search</a>
         </div>
         
         <div role = "main" class = "ui-content">
            <div id = "sorter">
               <ul data-role = "listview">
                  <li><span>A</span></li>
                  <li><span>B</span></li>
                  <li><span>C</span></li>
                  <li><span>D</span></li>
                  <li><span>E</span></li>
                  <li><span>F</span></li>
                  <li><span>G</span></li>
                  <li><span>H</span></li>
               </ul>
            </div>
            
            <ul data-role = "listview" data-autodividers = "true" id = "sortedList">
               <li><a href = "#">Albania</a></li>
               <li><a href = "#">Algeria</a></li>
               <li><a href = "#">Angola</a></li>
               <li><a href = "#">Bahamas</a></li>
               <li><a href = "#">Barbados</a></li>
               <li><a href = "#">Belgium</a></li>
               <li><a href = "#">Canada</a></li>
               <li><a href = "#">Cameroon</a></li>
               <li><a href = "#">China</a></li>
               <li><a href = "#">Denmark</a></li>
               <li><a href = "#">Dominica</a></li>
               <li><a href = "#">Djibouti</a></li>
               <li><a href = "#">Ecuador</a></li>
               <li><a href = "#">Egypt</a></li>
               <li><a href = "#">Estonia</a></li>
               <li><a href = "#">Fiji</a></li>
               <li><a href = "#">Finland</a></li>
               <li><a href = "#">France</a></li>
               <li><a href = "#">Georgia</a></li>
               <li><a href = "#">Germany</a></li>
               <li><a href = "#">Greece</a></li>
               <li><a href = "#">Haiti</a></li>
               <li><a href = "#">Hong Kong</a></li>
               <li><a href = "#">Hungary</a></li>
            </ul>
         </div>
         
         <div data-role = "footer">
            <h4>Footer</h4>
         </div>
      </div>
   </body>
</html>

输出

让我们执行以下步骤,看看上面的代码是如何工作的 −

  • 将上述 html 代码保存为服务器根文件夹中的 listview_autodivider_linkbar.html 文件。

  • 将此 HTML 文件打开为 http://localhost/listview_autodivider_linkbar.html,将显示以下输出。

❮ jQuery Mobile - 小部件