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

จัดสไตล์ <input> ที่ไม่มี Readonly ด้วย :read-write Selector

ใช้ :read-write เพื่อเลือก Element ที่แก้ไขได้ (ไม่มี Attribute readonly และไม่ได้ disabled)

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
    <style>
        input:read-write {
            background-color: blue;
            color: white;
        }
    </style>
</head>
<body>
    <form>
        Subject: <input type="text" name="subject" value="Java"><br>
        Student: <input type="text" name="student" readonly value="Amit"><br>
    </form>
</body>
</html>

ผลลัพธ์: Input "Subject" (แก้ไขได้) จะมีพื้นหลังสีน้ำเงิน ตัวอักษรสีขาว Input "Student" (readonly) จะไม่ได้รับผล