jQuery Mobile - 垂直分組 Selectmenu



描述

預設情況下,選擇選單按垂直方向設定。在欄位集中設定 data-role = "controlgroup" 屬性,可將多個 selectmenu 分組。

示例

以下示例演示瞭如何在 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 vertical group Example</h2>
      <form>
         <fieldset data-role = "controlgroup">
            <legend>Vertical group menu</legend>

            <label for = "select">Select</label>
            <select>
               <option value = "#">Maharastra</option>
               <option value = "#">Mumbai</option>
               <option value = "#">Pune</option>
            </select>

            <label for = "select">Select</label>
            <select>
               <option value = "#">Karnataka</option>
               <option value = "#">Bangalore</option>
               <option value = "#">Belgaum</option>
            </select>

            <label for = "select">Select</label>
            <select>
               <option value = "#">Tamil Nadu</option>
               <option value = "#">Chennai</option>
               <option value = "#">Ooty</option>
            </select>
            
         </fieldset>
      </form>
   </body>
</html>

輸出

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

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.