垂直控制組選擇選單



說明

預設情況下,選擇選單是垂直設定的。可在欄位集中設定 data-role = "controlgroup" 屬性,以便對自定義選擇選單進行分組。

舉例

以下示例演示了在 jQuery Mobile 中使用垂直 controlgroup 的 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>Vertical Controlgroup Example</h2>
      <fieldset data-role = "controlgroup">
         
         <label for = "select">Select</label>
         <select id = "select" data-native-menu = "false">
            <option value = "#">Maharastra</option>
            <option value = "#">Thane</option>
            <option value = "#">Mumbai</option>
            <option value = "#">Pune</option>
         </select>

         <label for = "select1">Select</label>
         <select id = "select1" data-native-menu = "false">
            <option value = "#">Karnataka</option>
            <option value = "#">Hubli</option>
            <option value = "#">Bangalore</option>
            <option value = "#">Belgaum</option>
         </select>

         <label for = "select2">Select</label>
         <select id = "select2" data-native-menu = "false">
            <option value = "#">Tamil Nadu</option>
            <option value = "#">Madurai</option>
            <option value = "#">Chennai</option>
            <option value = "#">Ooty</option>
         </select>
         
      </fieldset>
   </body>
</html>

輸出

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

  • 將上面的 html 程式碼另存為 selectmenu_custom_vertical_controlgroup.html 檔案,並將其儲存在伺服器根資料夾。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.