tags:

views:

44

answers:

1

Hi,

I hope I can word this okay.

I have multiple divs all called '.collapse-conten' and within each of these I have a table called '.collapseTable'. What I would like to do is check the number of rows within each table.

I have this code right now...

var num = $(".collapse-content tr").size(); alert(num);

This obviously returns all rows in the page and the number of rows per div named '.collapse-content'

Can someone please help with this.

Many thanks, Cj

+3  A: 
$(".collapse-content").each(function(){
    console.log($(this).find('.collapseTable tr').length);
});
PetersenDidIt
just to be a little more specific I would use .find(".collapseTable tr") just to make sure there isn't any other tr's. Besides that +1
T B
The .length property is a slightly faster way to get the count. Might be useful depending on home many tables/rows you are dealing with.
Shaun Humphries
Both of you are correct, fixed up the answer to use both.
PetersenDidIt
Perfect. Many thanks!
Model Reject