tags:

views:

663

answers:

1

hi,

I'm using a dynamic jQuery tab widget to add/remove tabs generated programmatically.

How do I check through jQuery and count how many existing tabs are present in the widget?

I'm using this code, but it doesn't work:

$('#container-1 > ul').tabs('add', tabName, name);

var newTab;

if ($('#container-1 > li').size() < 0) {
    newTab = $(tabName).css('display', 'block')
} else {
    newTab = $(tabName).css('display', 'none');
}

newTab.html('<iframe src="ViewPatient.aspx?pname=' + name 
       + '" width="100%" frameborder="0" scrolling="no" height="300"></iframe>');
+1  A: 
$('#container-1 > ul').tabs().size();
Robert Harvey
thanks, but this doesn't work on my setuphere's my html<div id="container-1"> <ul> </ul> </div> </div>
You need to make a selector that contains all of your tabs, then take the .size() of it.
Robert Harvey
solved it:$(tabContainer).tabs("length") < 1