jQuery Mobile - 可摺疊圖示



說明

可以使用 data-collapsed-icondata-expanded-icon 屬性覆蓋可摺疊標題的預設圖示。

示例

以下示例演示在 jQuery Mobile 中使用“可摺疊圖示”。

<!DOCTYPE html>
<html>
   <head>
      <title>Collapsible Icons</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-icon = "carat-d" data-expanded-icon = "carat-u">
         <h4>Heading</h4>
         <ul data-role = "listview" data-inset = "false">
            <li>Read-only item 1</li>
            <li>Read-only item 2</li>
            <li>Read-only item 3</li>
         </ul>
      </div>
   </body>
</html>

輸出

讓我們執行以下步驟,瞭解以上程式碼如何工作 −

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.