jQuery Mobile - 水平組選擇選單



說明

透過給欄位集包含 data-type = "horizontal" 來將選擇選單設定為水平。

示例

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

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

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

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

輸出

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

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

  • 開啟這個 HTML 檔案,作為 https:///selectmenu_horizontal_group.html,將會顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.