Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: filter with multiple classes

Tags:

jquery

filter

Is there a nice way to accomplish filtering selected elements down to a few classes? I know I could do them one at a time, but this just seemed to be something jQuery would allow.

These are being served up with ajax, and I don't have access to define the actual html.

$('.val>td').each(function () {
    $(this).filter('.price,.quantity,.remove').children().children().addClass('hidetaxfields');
});
like image 703
Adam Cook Avatar asked Feb 27 '13 01:02

Adam Cook


1 Answers

What you are asking isnt clear from the exmple you give...

This will produce a subset of the elements matched by the inital selector that have the class one OR two:

$(selector).filter('.one, .two');

This will produce a subset of the elements matched by the inital selector that have BOTH the classes one AND two:

$(selector).filter('.one.two');
like image 163
prodigitalson Avatar answered Sep 19 '22 12:09

prodigitalson