Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

บทบาทของ CSS :enabled Selector

ใช้ :enabled เพื่อจัดสไตล์ <input> ทุกตัวที่เปิดใช้งานอยู่ (ไม่มี attribute disabled)

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
    <style>
        input:enabled {
            background: blue;
        }
    </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>

ผลลัพธ์: Input Subject และ Student จะมีพื้นหลังสีน้ำเงิน Input Age (disabled) จะไม่ได้รับผล