Get count of rows in each table while having more than 1 tables

Posted by sneha khan on Stack Overflow See other posts from Stack Overflow or by sneha khan
Published on 2012-09-22T09:16:33Z Indexed on 2012/09/22 9:37 UTC
Read the original article Hit count: 236

Filed under:

I have more then one tables on same page and want to add a line show count of each table as below. I tried something but it gives sum of count of all table rows.

<table>
 <tr>
   <td>Some data</td>
   <td>More data</td>
 </tr>
 <tr>
   <td>Some data</td>
   <td>More data</td>
 </tr>
</table>

<table>
 <tr>
   <td>Some data</td>
   <td>More data</td>
 </tr>
 <tr>
   <td>Some data</td>
   <td>More data</td>
 </tr>
</table>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
 $().ready(function(){

  //I want to add a line after each table showing each table row count
  $("table").after(??? + " rows found.");
 });
</script>

© Stack Overflow or respective owner

Related posts about jQuery