Showing posts with label tbody. Show all posts
Showing posts with label tbody. Show all posts

Friday 24 October 2014

How to get the number of rows in a table - tbodyin jquery?

<table id="myTable" cellpadding="0" cellspacing="0">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Birth Date</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>John</td>
      <td>Smith</td>
      <td>03-11-1980</td>
    </tr>
  </tbody>
</table>

Solution:
$("#myTable tbody tr").length - Its wrong.
$("#myTable > tbody > tr").length; - Its right to get solution.