My tabs are created using PHP so I do not want a set width per tabswitcher tab. Due to this I am trying to add up the total width of the tabswitcher so I can set the width then apply a margin:0 auto;.
Alerting the var width is returning NaN. This is my first loop attempt, probably screwed up somewhere! (obviously...)
JQuery
var width;
var NumOfTabs = $('.TabSwitcher .Tab').length;
var count = 1;
while (count < NumOfTabs){
width = width + $('.TabSwitcher .Tab:nth-child(' + count + ')').width();
count++;
}
width = width + (NumOfTabs * 4) // Add passing
$('.TabSwitcher').css({'width': width + 'px'});
HTML
<div class="TabSwitcher">
<div class="Tab Active" id="Page_1">1</div>
<div class="Tab" id="Page_2">2</div>
</div>
var margin, is itvar widthinstead?widthis initiallyNULL. Hard to addNULL.