Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Event Target

DZone's Guide to

Event Target

·
Free Resource
Gets the target element from an event, cross broser

Usage:
getEventTarget( evt as Event );

Code:

function getEventTarget(evt) {
	var elem;
	if (evt.target) {
		elem = (evt.target.nodeType == 3) ? evt.target.parentNode : evt.target;
	} else {
		elem = evt.srcElement;
	}
	return elem;
}
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}