設定每個已停用的元素的樣式,使用 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>
廣告