Skip to content Skip to sidebar Skip to footer

Getting The Inner-most Row In The Embedded Tables

I have a table with nested tables.And the problem is that in mouse event listener, I would like to grab the deepest row. I've found this which is almost what I am looking for, but

Solution 1:

Event.stopPropagation() Prevents further propagation of the current event in the capturing and bubbling phases.

$(function() {
  $(document).on('mouseover', 'tr', function(e) {
    e.stopPropagation();
    console.log(this.id);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<table>
  <tbody>
    <tr id='1'>
      <td>A
        <table>
          <tbody>
            <tr id='2'>
              <td>B</td>
            </tr>
            <tr id='3'>
              <td>C</td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

Post a Comment for "Getting The Inner-most Row In The Embedded Tables"