Preselect Tab

Permalink
Hi

I have added tabs to a single_page using this code.
<script type="text/javascript">
   $(document).ready(function(){
      $('#tabset a').click(function(ev){
         var tab_to_show = $(this).attr('href');
         $('#tabset li').
            removeClass('ccm-nav-active').
            find('a').
            each(function(ix, elem){
               var tab_to_hide = $(elem).attr('href');
               $(tab_to_hide).hide();
            });
         $(tab_to_show).show();
         $(this).parent('li').addClass('ccm-nav-active');
         return false;
      }).first().click();


This works great.

What I now need, es a way to set the second tab active on page load.

Any ideas?
thanks

Steff
 
Arequal replied on at Permalink Reply
Arequal
$('#yourtabId').click();

Raise a click event on the tab you want to activate

In this case you are raising event in the first one... so delete it and click on the second
Steff replied on at Permalink Reply
Steff
Thanks for pointing me to the right direction.

$('#tabset li').find('a[href="#tab2content"]').click();


That's what I was looking for.
Arequal replied on at Permalink Reply
Arequal
You're welcome.