Getting source element of onclick event
I'm trying to add an onclick of a link and, in the handler function, get a reference to the clicked element.
I thought this code should work, and work across browsers:
Works fine in IE However in firefox e is undefined. What am i doing wrong?
if (!e) var e = window.event;
<a href='#' onclick="getit(); return false;">click</a>
I know it's possible, so I wanted to figure it out rather than resort to passing 'this' along with every function call.