There are ways of registering Events to objects in an HTML file. So this way an object is set to detect events.
In case we think 2 div elements one inside other; If i attach an onClick event to inner div; this means outer div was not attached one. So it should NOT detect the click event. Why still we need to use stopPropagation () ? since we did not attach any other event detection...
addEventListener
, and give it an hour to sink in... – Yvette<tr>
. That would mean you'd need to bind handlers not only to the<tr>
but to all its<td>
children and all descendants of all<td>
elements. That would be obnoxious, especially when it is more natural to say when you click a child, you're also clicking its ancestors, which is true. – Margitmargodiv
, but then some other code puts a handler on something else inside thatdiv
, why should it prevent your handler from working when clicking that inner element? What if you nested handlers intentionally and want both to be invoked? Then what would you do? – Margitmargo