When you organize an event handler to respond to clicks, the browser will install everything so that you can figure out which item was clicked (the "target" of the event). In your Javascript, you can do something like this, assuming your <table> is the only table on the page:
function handleRowClicks(e) { e = e || window.event; if (!e.target.tagName.toLowerCase() === "tr") return; var rowId = e.target.id; }
This is just one of many different approaches. If you used the Javascript framework / library, it would be a little simplified, perhaps, but not much.
Note that this approach handles clicks at the <table> level instead of the rows themselves. This makes initialization a little easier.
source share