jQuery Mobile - 已停用選項的 Selectmenu



說明

在 <option> 元素中設定屬性 disabled = "disabled" 以停用自定義下拉選單選項。

示例

以下示例演示了在 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 Empty 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 = "mu">Mumbai</option>
            <option value = "pu" disabled = "disabled">Pune</option>
            <option value = "be" >Belgaum</option>
            <option value = "ch">Chennai</option>
            <option value = "ban">Bangalore</option>
         </select>
         
      </div>
   </body>
</html>

輸出

讓我們執行以下步驟來檢視以上程式碼如何工作 -

  • 將上述 HTML 程式碼另存為 selectmenu_custom_disabled.html 檔案,並將其儲存在您的伺服器根資料夾中。

  • 以 https:///selectmenu_custom_disabled.html 的形式開啟此 HTML 檔案,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.