add/remove active class on mouseover mouseleave
<p>I need a little help with a script i modified.</p>

<p>I've created a submenu and now I want to remove the class .active_2 while hovering. If I remove the mouse class .active_2 should be added.</p>

<p>This is my code so far:</p>

<pre><code>    $(function() {
      var $menu = $('#sub_nav');

      $menu.children('li').each(function(){
        var $this = $(this);
        var $span = $this.children('span');
        $span.data('width',$span.width());

        $this.bind('mouseenter',function(){
          $menu.find('.sub_nav_sub').stop(true,true).hide();
          $menu.find('.active_2').removeClass();
          $span.stop().animate({'width':'170px'},300,function(){
            $this.find('.sub_nav_sub').slideDown(300);
          });
          }).bind('mouseleave',function(){
            $this.find('.sub_nav_sub').stop(true,true).hide();
                            /* addClass here */
            $span.stop().animate({'width':$span.data('width')+'px'},300);
          });
      });
    });
</code></pre>

<p>CSS:</p>

<pre><code>.active_2, .active_2 a {
  background: #FBD009;
  color: #000000!important;
}
</code></pre>

<p>HTML:</p>

<pre><code>&lt;ul id="sub_nav" class="sub_nav"&gt;
  &lt;li class="active_2"&gt;&lt;a href="aktuelles.html"&gt;News&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span&gt;Termine&lt;/span&gt;
    &lt;ul class="sub_nav_sub"&gt;
      test
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>Removing Class works just fine but adding class isn't working.
I've tried:</p>

<pre><code>$(this).addClass('.active_2');
</code></pre>

<p>Edit:
I didn't make a correct formulation of my problem, so here again:</p>

<p>I want to remember which li was active before and set it to the li when the mouse leaves the navigationbar.</p>

<p>For example: News is active. While hovering News it is not active anymore but all others li while sliding over. If I remove the mouse from the navigationbar News should be active again.</p>

<p>I thought that I should search for the li which has the class active_2 and then addClass active_2</p>

<pre><code>$(this).find('li.active_2').addClass('active_2');
</code></pre>

<p>But this seems not to be the right choice. Any suggestions?</p>
