开发者

jQuery: Select <classname1> but filter out <classname2>

开发者 https://www.devze.com 2023-03-25 14:34 出处:网络
jQuery Validation plugin can generate two types of labels, one with class=\"error\" and the other has class=\"error valid\".

jQuery Validation plugin can generate two types of labels, one with class="error" and the other has class="error valid".

I ha开发者_如何学Gove the following code to detect the existence of labels with class="error":

($form.find("label.error").not($form.find("label.valid")).length == 0);

Is there any other better (ie. more optimized) way doing this? Thanks.


Try something like this $('div.error:not(.valid').css('background-color', 'red'); as seen in this jsFiddle


I think it is enough to know only information about '.error' class name,

($form.find("label.error").length == 0);

or

(!$form.find("label.error").length);
0

精彩评论

暂无评论...
验证码 换一张
取 消