Board Thread:Support Requests - Getting Technical/@comment-3271569-20131223152502

I'm currently working on an add class table tab system for w:c:dragoncity:Eggs. I managed to code an raw sample for it. And I was wondering if you have some suggestions how I could improve it.

JS
") var countTerra2 = $('table#eggs-unbreedable-exclusive_hybrid tr.tabTerra2').length; for ( var i = 1; i < countTerra2 / 4; i++ ) { $("table#nav-eggs-unbreedable-exclusive_hybrid-terra tr").append(" ") } $('.clickTerra-0').click(function{  $('table#nav-eggs-unbreedable-exclusive_hybrid-terra td').removeClass('active');   $('.clickTerra-0').addClass('active');   $('.tabTerra2').removeClass('activeTerra');   $('.exclusive_terra-0').addClass('activeTerra'); }); $('.clickTerra-1').click(function{   $('table#nav-eggs-unbreedable-exclusive_hybrid-terra td').removeClass('active');   $('.clickTerra-1').addClass('active');   $('.tabTerra2').removeClass('activeTerra');   $('.exclusive_terra-1').addClass('activeTerra'); }); $('.clickTerra-2').click(function{   $('table#nav-eggs-unbreedable-exclusive_hybrid-terra td').removeClass('active');   $('.clickTerra-2').addClass('active'); $('.tabTerra2').removeClass('activeTerra'); $('.exclusive_terra-2').addClass('activeTerra'); }); $('.clickTerra-3').click(function{ $('table#nav-eggs-unbreedable-exclusive_hybrid-terra td').removeClass('active'); $('.clickTerra-3').addClass('active'); $('.tabTerra2').removeClass('activeTerra'); $('.exclusive_terra-3').addClass('activeTerra'); }); $('.clickTerra-4').click(function{ $('table#nav-eggs-unbreedable-exclusive_hybrid-terra td').removeClass('active'); $('.clickTerra-4').addClass('active'); $('.tabTerra2').removeClass('activeTerra'); $('.exclusive_terra-4').addClass('activeTerra'); }); });

Other Ideas
I would like to make this automated based on the amount of index:

So like:
 * if countTerra2 = x
 * function above will be called (loop) 