jQuery: Adding class to the li element after the link is clicked, and deselecting all other classes

Posted by Oleg Tarasenko on Stack Overflow See other posts from Stack Overflow or by Oleg Tarasenko
Published on 2010-03-12T19:30:18Z Indexed on 2010/03/12 19:37 UTC
Read the original article Hit count: 242

Filed under:
|

Hi,

I am generating menu with such tags:

<div class="animatedtabs">
  <ul>
    {% for item in menu_items %}
    <li><a href="{{ item.url }}" title="{{ item.name }}"><span>{{ item.name }}</span></a></li>
    {% endfor %}
  </ul>
</div>

What I want to do, I want to add class="selected" to li, after the link is clicked, and to remove all other class="selected" on other li's...

Also I wonder, how to show menu in the way, so the first item is selected by default... But then when another linked is clicked, then class="selected" is toggled

© Stack Overflow or respective owner

Related posts about django

Related posts about jQuery