jQuery Mobile - 迷你尺寸選擇選單



說明

為建立迷你版本的自定義選擇選單,請包含屬性 data-mini = "true"。它適用於工具欄和狹窄空間中的更緊湊版本。

示例

以下示例演示了在 jQuery Mobile 中使用迷你尺寸自定義選擇選單。

<!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>Selectmenu mini sized Example</h2>
      <div class = "ui-field-contain">
         <label for = "select-custom">Custom Select</label>
         
         <select id = "select-custom" data-native-menu = "false" data-mini = "true">
            <option value = "mu">Mumbai</option>
            <option value = "pu">Pune</option>
            <option value = "be">Belgaum</option>
            <option value = "ch">Chennai</option>
            <option value = "ban">Bangalore</option>
         </select>
         
      </div>
   </body>
</html>

輸出

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

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.