Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - select subset of elements within a saved set of elements

From this:

var $saved = $('#parent').find('a');

How can I now subselect those elements in $saved which have class myClass?

I don't want descendents (so find or children are no good), I want the subset of $saved.

var $refined = $saved.[something something];

Essentially, I want $refined to be equal to $('#parent').find('a.myClass'); but to start from $saved.

Thanks.

like image 817
Nick Avatar asked Sep 15 '12 10:09

Nick


1 Answers

You can use filter method:

var $refined = $saved.filter(".myClass");
like image 101
riofly Avatar answered Oct 21 '22 08:10

riofly