You can cache the set, and then run a filter against the set, which checks for another class, and compare the properties of .lengthboth.
var many_items = $('.many-items-of-this-class');
if( many_items.length === many_items.filter('.some-other-class').length ) { }
Or shorter, but perhaps more confusing, you can use a filter .not()with .lengthand !.
var many_items = $('.many-items-of-this-class');
if( !many_items.not('.some-other-class').length ) { }
source
share