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:
- Use
event.stopPropagation()
- Also note that
td
is child oftr
, not vice versa
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);
});
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><table><tbody><trid='1'><td>A
<table><tbody><trid='2'><td>B</td></tr><trid='3'><td>C</td></tr></tbody></table></td></tr></tbody></table>
Post a Comment for "Getting The Inner-most Row In The Embedded Tables"