jQuery Mobile - Collapsible Markup


The collapsibles set can be created with the same markup as basic collapsible. Adding data-role="collapsibleset" attribute will make it a collapsible set and behave like a accordion.


Following example demonstrates the use of collapsible set in jQuery Mobile.

<!DOCTYPE html>
      <title>Collapsible Markup</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">
      <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 = "collapsibleset" data-theme = "a" data-content-theme = "a">
         <div data-role = "collapsible">
            <h3>Heading 1</h3>
            <p>Hi!! This is collapsible content for heading 1</p>
         <div data-role = "collapsible">
            <h3>Heading 2</h3>
            <p>Hi!! This is collapsible content for heading 2</p>
         <div data-role = "collapsible">
            <h3>Heading 3</h3>
            <p>Hi!! This is collapsible content for heading 3</p>


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

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

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

Kickstart Your Career

Get certified by completing the course

Get Started