多重選擇選項 Selectmenu



描述

multiple = "multiple" 包含在 <select> 元素中,以在自定義列表檢視中建立多個選定選項。

示例

以下示例演示如何在 jQuery Mobile 中的 Select 選單中的多個選擇選項。

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

輸出

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

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.