unclick other when click one of them
Hi
let's say that I have a collection of DIVs into a section with ID
- <section id="cats">
- <div class="cat"></div>
- <div class="cat"></div>
- <div class="cat"></div>
- <div class="cat"></div>
- </section>
when I click on one of them I want to add a class but to remove that class from all other items in the collection
to get
- <section id="cats">
- <div class="cat cat-click"></div>
- <div class="cat"></div>
- <div class="cat"></div>
- <div class="cat"></div>
- </section>
and if I click on the item itself or any of items in the collection I must get only one with cat-clicked an dof course only into the section id=cats
something like
- $(".cat").each(function() {
- $(this).click(function() {
- $(this).toggleClass('cat-click');
- });
- });
thanks for helping