I'm trying to stay on a specif tab ( in this case tab2 ) but after clicking the submit button the tab reverts to tab 1 which has the default class of active. I have hit a brick wall with this one.

Here is my example **[[jsfiddle]](http://jsfiddle.net/cwHQA/1/)**:

HTML:

```
<ul class='tabs'>
            <li><a href='#tab1'>Tab 1</a></li>
            <li><a href='#tab2'>Tab 2</a></li>
        </ul>
<div id='tab1'>
            <h3>Section 1</h3>
            <p>Lorem ipsum dolor sit amet, consssectetur adipiscing elit. Donec lobortis placerat dolor id aliquet. Sed a orci in justo blandit commodo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.</p>
                <form id="form1" action="" method="post">            
      <input id="button-1" name="" type="submit" />
</form>
        </div>
<div id='tab2'>
<a name="tab2"></a>
            <h3>Section 2</h3>
            <p>Aenean et est tortor. In pharetra pretium convallis. Mauris sollicitudin ligula non mi hendrerit varius. Fusce convallis hendrerit mauris, eu accumsan nisl aliquam eu.</p>

    <form id="form2" action="" method="post">            
      <input id="button-2" name="" type="submit" />
</form>
        </div>
<div>
  <h2>RESULTS </h2>
</div>        

```

JavaScript:

```
$(document).ready(function(){
    $('ul.tabs').each(function(){
        var $active, $content, $links = $(this).find('a');
        $active = $links.first().addClass('active');
        $content = $($active.attr('href'));
        $links.not(':first').each(function () {
            $($(this).attr('href')).hide();
        });

        $(this).on('click', 'a', function(e){
            $active.removeClass('active');
            $content.hide();
            $active = $(this);
            $content = $($(this).attr('href'));
            $active.addClass('active');
            $content.show();
            e.preventDefault();
        });
    });
});

```

​
CSS:

```
*         {padding:0; margin:0;}
html      {padding:15px 15px 0;font-family:sans-serif;font-size:14px;}
p, h3     {margin-bottom:15px;}
div       {padding:10px;width:600px;background:#fff;}
ul.tabs   {margin-left:2px;}
#tab1, #tab2 {border-top: solid 1px #ccc;margin-top: -1px; }
#tab2      {display:none;}a
ul.tabs li  {list-style:none;display:inline;}
ul.tabs li a   {padding:5px 10px;display:inline-block;background:#666;color:#fff;text-decoration:none;}
ul.tabs li a.active {background:#fff;color:#000;border: solid 1px #ccc; border-width: 1px 1px 0 1px;}

```

​

Your help would be greatly appreciated