title: How to find which row I just clicked in javascript
body: <p>I can't find the appropriate answer of my problem. I have rows in a table and every row contain one button. How to find the row index of button I just clicked.</p>
  
  <pre><code>&lt;tr&gt;
      &lt;td&gt;111&lt;/td&gt;
      &lt;td&gt;aaa&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="first" id="first" value="First" onclick="countRow(this.id)" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;222&lt;/td&gt;
      &lt;td&gt;bbb&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="sec" id="second" value="Second" onclick="countRow(this.id)" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;333&lt;/td&gt;
      &lt;td&gt;ccc&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="third" id="third" value="Third" onclick="countRow(this.id)" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>