jQuery Mobile - 標準圖示列表檢視



說明

新增屬性 data-icon 以設定特定列表項的圖示,可以透過包含任何標準圖示的名稱來設定不同型別的圖示。

示例

以下示例演示了在 jQuery Mobile 中列表中使用 data-icon。

<!DOCTYPE html>
<html>
   <head>
      <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>
      <h2>Icon Standard List Example</h2>
      <ul data-role = "listview" data-inset = "true">
         <li data-icon = "custom"><a href = "#">Inbox</a></li>
         <li data-icon = "gear"><a href = "#">Setting</a></li>
         <li data-icon = "info"><a href = "#">Important</a></li>
         <li data-icon = "delete"><a href = "#">Chats</a></li>
      </ul>
   </body>
</html>

輸出

讓我們執行以下步驟,看看上面的程式碼是如何工作的 −

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.