無值選項選擇選單



描述

<option> 標記用於定義選單列表中的專案,其中 value = "" 屬性設定 name 屬性中變數的預設值。

示例

以下示例演示瞭如何在 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 Option Value Example</h2>
      <div class = "ui-field-contain">
         <label for = "select-custom">Custom Select</label>
         
         <select id = "select-custom" data-native-menu = "false">
            <option value = "choose-one">Choose any one</option>
            <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_option_value.html 檔案。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.