樣式化每個停用的element,使用 CSS


若要樣式化每個已停用的 <input> 元素,請使用 CSS :disabled 選擇器。您可以嘗試執行以下程式碼來設定停用元素的樣式 −

示例

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:enabled {
            background: blue;
         }
         input:disabled {
            background: red;
         }
      </style>
   </head>
   <body>
      <form action = "">
         Subject <input type = "text" name = "subject"><br>
         Student: <input type = "text" name = "student"><br>
         Age: <input type = "number" name = "age" disabled><br>
      </form>
   </body>
</html>

更新於: 2020 年 6 月 30 日

485 次瀏覽

開啟您的職業道路

完成課程獲取認證

開始
廣告