jQuery Mobile - Tabbed page content


You can swap out the entire page contents using the tabs.


Following example demonstrates the use of tabbed page content in jQuery Mobile.

<!DOCTYPE html>
      <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>
      <div data-role = "page" class = "jqm-demos" data-quicklinks = "true">
         <div data-demo-html = "true">
            <div data-role = "tabs">
               <div data-role = "navbar">
                        <a href = "#one" data-theme = "a" data-ajax = "false">Tab one</a>
                        <a href = "#two" data-theme = "a" data-ajax = "false">Tab two</a>
                        <a href = "/jquery_mobile/src/tabs_navbars2.html" data-theme = "a" 
                           data-ajax = "false">Tab three</a>
               <div id = "one" class = "ui-content">
                  <h1>This is first tab content</h1>
               <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>
            <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>


Let's carry out the following steps to see how the above code works −

  • Save the above html code as tabs_page_content.html file in your server root folder.

  • Open this HTML file as http://localhost/tabs_page_content.html and the following output will be displayed.

Kickstart Your Career

Get certified by completing the course

Get Started