jQuery 移動版 - 圖示左部選擇選單



描述

預設情況下,自定義選擇選單圖示設定在右側。使用 data-iconpos = "left" 屬性可以將自定義 selectmenu 圖示按鈕的位置設定為左側。

示例

以下示例演示了在 jQuery 移動版中使用 selectmenu 中的左圖示。

<!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 Icon Left Position Example</h2>
      <div class = "ui-field-contain">
         <label for = "select-custom">Custom Select</label>
         
         <select id = "select-custom" data-native-menu = "false" data-iconpos = "left">
            <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_icon_left.html 檔案,並儲存到伺服器根資料夾中。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.