When I have a table and click on a tr element, the function returns a td element instead. Can someone explain why this is happening?
let func = function () {
$("tr").on("click", (event) => {
event.preventDefault();
event.stopPropagation();
console.log(event.isPropagationStopped()); // true
let targetEl = $(event.target);
console.log(targetEl); // Object [ td ]
});
};
func();
I would like the "onclick" to return the tr element instead of the td, but I'm not sure what's causing this issue. Any help would be appreciated.