Table Row Counter

by Carl Angelo Nievarez

HTML

<button id="rowCount">Count 'Em</button>
<br />
<table id="myTable">
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
</table>

JavaScript

$(function() {
  $('#rowCount')
    .button()
    .click(function() {
      alert("Rows = " + ($('table#myTable tr:last').index() +1-2));
    })
});