views:

24

answers:

1
$('.tabbed-block .tab-content:first').show();
            $('.tabbed-block ol li:first').addClass('active');
            $('.tabbed-block ol li a').click(function () {
                $('.tabbed-block ol li').removeClass('active');
                $(this).parent().addClass('active');
                var a = $(this).attr('href');
                $('.tabbed-block .tab-content').hide();
                $(a).show();
                return false;
            });

.. works great, but not if used more than once of the same page, interferes with each other. What should I change?

Thanks!

+1  A: 

This should work. Although, why aren't you just using jQuery UI Tabs?

$('.tabbed-block').each(function(){
  var $block = $(this);
  $block.find('.tab-content:first').show();
  $block.find('ol li:first').addClass('active');
  $block.find('ol li a').click(function () {
    var $link = $(this);
    $link.closest('ol').find('li a').removeClass('active');
    $link.parent().addClass('active');
    var a = $link.attr('href');
    $link.closest('.tabbed-block').find('.tab-content').hide();
    $(a).show();
    return false;
  });
});
BBonifield
Made this change: `$link.parent().addClass('active').siblings().removeClass('active');` Otherwise Perfect, thansk!!
Nimbuz