[英]How can I check element have class or not in jQuery validate?
On the highlight, I try like this : 在亮点上,我尝试这样:
unhighlight: function (element, errorClass, validClass) {
if(element.prop("class") == "test")
document.getElementById('error-message-test').style.display = 'none';
}
There exist error : 存在错误:
element.prop is not a function
element.prop不是函数
How can I solve this error? 我该如何解决这个错误?
You can use jQuery
to wrap your element or with hasClass
like: 您可以使用
jQuery
包装元素或使用hasClass
例如:
if($(element).prop("class") == "test")
Or 要么
if($(element).hasClass("test"))
You can use hasClass method of jQuery if an element has class or not. 如果元素具有类,则可以使用jQuery的hasClass方法。
General syntax 一般语法
if($(element).hasClass('className'))
Based on your scenario 根据您的情况
if($(element).hasClass('test'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.