jQuery Mobile - 停用選項



說明

在 <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 Disabled option Example</h2>
      <form>
         <div class = "ui-field-contain">
            <label for = "select">Select Menu</label>
            
            <select name = "select" id = "select">
               <option value = "1">Belgaum</option>
               <option value = "2">Pune</option>
               <option value = "3">Chennai</option>
               <option value = "4" disabled = "disabled">Bangalore</option>
               <option value = "5">Mumbai</option>
            </select>
            
         </div>
      </form>
   </body>
</html>

輸出

執行以下步驟瞭解上述程式碼的工作原理 −

  • 將上述 html 程式碼另存為selectmenu_disabled_option.html 檔案,儲存到伺服器根資料夾中。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.