jQuery Mobile - 可摺疊標記



簡介

可摺疊集合可以使用與基本可摺疊相同的標記來建立。新增data-role="collapsibleset"屬性會使其成為可摺疊集合,並表現得像手風琴。

示例

以下示例演示了在 jQuery Mobile 中使用可摺疊集合

<!DOCTYPE html>
<html>
   <head>
      <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>
   </head>

   <body>
      <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>
         
         <div data-role = "collapsible">
            <h3>Heading 2</h3>
            <p>Hi!! This is collapsible content for heading 2</p>
         </div>
         
         <div data-role = "collapsible">
            <h3>Heading 3</h3>
            <p>Hi!! This is collapsible content for heading 3</p>
         </div>
      </div>
   </body>
</html>

輸出

讓我們執行以下步驟來了解上面程式碼的工作原理:

  • 將上面的 html 程式碼儲存為伺服器根資料夾中的collapsible_markup.html檔案。

  • 將此 HTML 檔案作為 https:///collapsible_markup.html 開啟,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.