Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Tested and, demonstrably, working:</p> <pre><code>$('input:checkbox').change( function(){ var show = $('input:checkbox:checked').map(function(){ return $(this).val(); }); console.log(show); $('#list li').each( function(){ if ($.inArray($(this).attr('class'),show) &gt; -1) { $(this).show(); } else { $(this).hide(); } }); }); </code></pre> <p><a href="http://jsfiddle.net/davidThomas/Ck8Nr/" rel="nofollow">JS Fiddle demo</a>.</p> <p>Note that, for the sake of simplicity, and to avoid the <code>not()</code> method, I opted to assign an <code>id</code> to the list containing the elements to be filtered.</p> <hr /> <p><strong>Edited</strong> in response to comment from OP:</p> <blockquote> <p>[Only] one problem, when you deselect all the checkboxes after selecting any of them all the results vanishes...</p> </blockquote> <pre><code>$('input:checkbox').change( function(){ var show = $('input:checkbox:checked').map(function(){ return $(this).val(); }); if (show.length &gt; 0){ $('#list li').each( function(){ if ($.inArray($(this).attr('class'),show) &gt; -1) { $(this).show(); } else { $(this).hide(); } }); } else { $('#list li').show(); } }); </code></pre> <p><a href="http://jsfiddle.net/davidThomas/Ck8Nr/1/" rel="nofollow">JS Fiddle demo</a>. References:</p> <ul> <li><a href="http://api.jquery.com/array/" rel="nofollow"><code>attr()</code></a>.</li> <li><a href="http://api.jquery.com/change/" rel="nofollow"><code>change()</code></a>.</li> <li><a href="http://api.jquery.com/checkbox-selector" rel="nofollow"><code>:checkbox</code> selector</a>.</li> <li><a href="http://api.jquery.com/hide/" rel="nofollow"><code>hide()</code></a>.</li> <li><a href="http://api.jquery.com/input-selector/" rel="nofollow"><code>:input</code> selector</a>.</li> <li><a href="http://api.jquery.com/jquery.inArray/" rel="nofollow"><code>$.inArray()</code></a>.</li> <li><a href="http://api.jquery.com/map/" rel="nofollow"><code>map()</code></a>.</li> <li><a href="http://api.jquery.com/show/" rel="nofollow"><code>show()</code></a>.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload