📜  js find :invalid inside div - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:47.353000             🧑  作者: Mango

代码示例1
var contactForm = document.getElementById('contact-form');
if (contactForm.checkValidity() == false) {
    var list = contactForm.querySelectorAll(':invalid');
    for (var item of list) {
        item.setAttribute("style", "background-color: red;")
    }
}