JQuery search in array of object

Lets say I have this html :

<li class="cls">one</li>
<li class="cls active">tow</li>
<li class="cls">here</li>
<li class="cls">after</li>

I'm selecting all .cls by this jquery selector : $('.cls') and put them in a variable:

var c=$('.cls');

c is an array of object now. I want to select .active item in this array by jQuery methods. I do know i can use $('.cls.active') but this is not what I'm lookin for. I want to use c. Is there any solution ?

note: c.find('.active') not working, because .find() searching in childs.

use filter() instead of find()


Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.


Reduce the set of matched elements to those that match the selector or pass the function's test.


Simply use the filter() method of the jQuery object:

var active = c.filter('.active');

JS Fiddle proof-of-concept.


Use .filter()


Use .filter()