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.jquery.com/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.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> <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 文件打开为 http://localhost/tabs_page_content.html,将显示以下输出。