jQuery Mobile - 基本可摺疊的



說明

可摺疊的內容塊,可使用 data-role = "collapsible" 屬性建立到容器。可在容器內新增任何標題或圖例元素。標題將被框架設計為看起來像可點選按鈕。

可在標題下方新增您選擇的 HTML 標記,當單擊標題時,將顯示/隱藏該標記。

示例

以下示例說明了在 jQuery Mobile 中使用基本可摺疊

<!DOCTYPE html>
<html>
   <head>
      <title>Basic collapsible</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">
         <legend>Heading</legend>
         <p>Hi! This is collapsible content.</p>
      </div>
   </body>
</html>

輸出

讓我們執行以下步驟來檢視上面的程式碼如何工作 −

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.