jQuery Mobile - 摺疊展開



說明

在頁面載入時,透過將 data-collapsed 屬性設定為 false,可以展開可摺疊內容。

示例

以下示例演示了在 jQuery Mobile 中使用 展開的可摺疊內容

<!DOCTYPE html>
<html>
   <head>
      <title>Collapsible Expanded</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 = "collapsible" data-collapsed = "false">
         <h4>Heading</h4>
         <ul data-role = "listview">
            <li><a href = "#">Item 1</a></li>
            <li><a href = "#">Item 2</a></li>
            <li><a href = "#">Item 3</a></li>
         </ul>
      </div>
   </body>
</html>

輸出

讓我們執行以下步驟來了解上述程式碼如何工作 −

  • 將以上 html 程式碼作為 collapsible_expanded.html 檔案儲存在伺服器根資料夾中。

  • 以 https:///collapsible_expanded.html 形式開啟此 HTML 檔案,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.