I\'m trying get the element clicked within a TR in a HTML table. If I click on the Select input inside a TR, CurrentTarget
field returns \"TR\", and OriginalT
You haven't actually said what trb
is but it sounds like it might be a set of the tr
elements in your table.
What you're looking for is elem.target
. That's the topmost element that was clicked, the one that initiated the event. (FWIW, I wouldn't call the argument passed to the event handler elem
, it's an event, not an element.)
For instance, if you have:
Click me
...and this:
$("tr").click(function(e) {
console.log(e.target.tagName);
});
...and you click the text "click me," you'll see
STRONG
...in the console.
Side note: It's handy to use closest with that if you want to know what cell or row was clicked, e.g.:
var $td = $(e.target).closest('td');