Quick question, is it possible to put an onclick event handler on a <table> element? At the moment I’ve got a handler on each <tr> to detect when a row is clicked, but I was thinking it would be simpler and more efficient if I could have a single event handler for the whole table and then use event.target to find which row was clicked.
Quick question, is it possible to put an onclick event handler on a <table>
Share
Sounds like you want event delegation:
jQuery: http://api.jquery.com/delegate/
raw: http://davidwalsh.name/event-delegate