 <p>You can do this way:</p> <pre><code>var filters = {}; //when a link in the filters div is clicked... $('#content ul li').not(':first').hide(); $('#filters a').click(function(e){ e.preventDefault(); filters[$(this).parent().attr('class')] = $(this).attr('id'); var show = $('#content ul li').filter(function(){ for(k in filters) if( filters.hasOwnProperty(k) &amp;&amp; !$(this).hasClass(filters[k]) ) return false; return true; }); $('#content ul li').not(show).hide(); show.fadeIn(); $('pre:first').html(JSON.stringify(filters)); }); }); </code></pre>