开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜