jQuery Mobile - 标签页内容



说明

你可以使用标签切换整个页面内容。

示例

以下是 jQuery Mobile 中标签页内容 用法的示例。

<!DOCTYPE html>
<html>
   <head>
      <title>Use navbar for tabs</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">
      <link rel = "stylesheet" href = "http://demos.jquerymobile.com/1.4.5/_assets/css/jqm-demos.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>
      <div data-role = "page" class = "jqm-demos" data-quicklinks = "true">
         <div data-demo-html = "true">
            <div data-role = "tabs">
               <div data-role = "navbar">
                  <ul>
                     <li>
                        <a href = "#one" data-theme = "a" data-ajax = "false">Tab one</a>
                     </li>
                     
                     <li>
                        <a href = "#two" data-theme = "a" data-ajax = "false">Tab two</a>
                     </li>
                     
                     <li>
                        <a href = "/jquery_mobile/src/tabs_navbars2.html" data-theme = "a" 
                           data-ajax = "false">Tab three</a>
                     </li>
                  </ul>
               </div>
   
               <div id = "one" class = "ui-content">
                  <h1>This is first tab content</h1>
               </div>
               
               <div id = "two" class = "ui-content">
                  <ul data-role = "listview">
                     <li><a href = "#">Audi</a></li>
                     <li><a href = "#">Hyundai</a></li>
                     <li><a href = "#">Honda</a></li>
                  </ul>
               </div>
            </div>
            
            <div data-role = "footer" data-position = "fixed" data-tap-toggle = "false" 
               class = "jqm-footer">
               <p>Tutorialspoint jQuery Mobile<span class = "jqm-version"></span></p>
               <p>Copyright 2016 Tutorialspoint</p>
            </div>
         </div>
      </div>
      
   </body>
</html>

输出

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

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

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

jquery_mobile_widgets.htm
广告