Filtering content (jQuery)

Posted by Nimbuz on Stack Overflow See other posts from Stack Overflow or by Nimbuz
Published on 2010-04-24T09:38:30Z Indexed on 2010/04/24 9:43 UTC
Read the original article Hit count: 232

Filed under:
|
|
|
|

HTML:

<div class="filter">
    <a href="#category-1">category 1</a>
    <a href="#category-2">category 2</a>
</div>
<ul class="items">
    <li class="category-1">item 1</li>
    <li class="category-1">item 2</li>
    <li class="category-2">item 3</li>
    <li class="category-2">item 4</li>
</ul>

What I want is for example clicking on 'category 1' link should hide all other category items from the list.

I understand jQuery's .filter() selector can be used but I'm not sure how to implement it for my purpose here.

Thanks for your help!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery