重点是,我尝试这样:
unhighlight: function (element, errorClass, validClass) {
if(element.prop("class") == "test")
document.getElementById('error-message-test').style.display = 'none';
}
存在错误:
element.prop is not a function
如何解决这个错误?
最佳答案
您可以使用jQuery
来包装您的元素或使用hasClass
,例如:
if($(element).prop("class") == "test")
或者
if($(element).hasClass("test"))
关于javascript - 如何在 jQuery 验证中检查元素是否具有类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47129661/