views:

549

answers:

1

Is it possible to rename all the tabs in a jQuery UI tab control? My tabs are numbered from 1..N, and it is possible to remove a tab from it. I want to "rename" the remaining tabs so they are numbered 1,2,3,4,5,6, and 1,2,3,5,6,7 when you remove the fourth tab. They should end up named by their 1-based index.

+1  A: 

If you're using Tabs_3, then it's very easy. Simply:

var n = 1;
$('#example > ul span').each(function() { this.innerHTML=n;n++; });
geocar
your inner block can be this.innerHTML=n++;
Mike Scott
Thanks, this works great. I should have realized Tabs_3 picks up changes to the underlying HTML.
Vegard Larsen
Mike: Can it? I'm suspicious of mixing numeric operators with magic strings (like innerHTML) - do all browsers support that correctly? (I can't check now)
geocar
Vegard: Tabs_3 simply modifies the style properties of the dom, and adds some event handlers; a quick check with Firebug showed it didn't mutate the dom at all.
geocar