Ahok Ahok - 1 year ago 68
jQuery Question

How to count tables inside a cell of table with jQuery

I have some tables nested inside a cell table, I want to count how many table inside that cell with jQuery, is that possible?

<td colspan="6">
<table class="groupbycountry" id="spain">
<thead> a row of col title </thead>
<tbody> rows of data</tbody>
<table class="groupbycountry" id="italy">
<thead>a row of col title</thead>
<tbody>rows of data </tbody>
//and many more table of country according the user input

<td colspan="6">
<table name="inputdata">
<form name="myprofile">
//the input tag

Is that possible to count tables
inside that parent table?

Ram Ram
Answer Source

you can use jQuery length property which returnes the number of selected elements, try the following:

var len = $('table:eq(0) .groupbycountry').length


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download