Best way to get the Original Target
You can do it in one line with var originalElement = e.srcElement || e.originalTarget;
but it ain't pretty JQuery-like ;-)
[Edit: But according to http://docs.jquery.com/Events/jQuery.Event#event.target event.target
might do...]
I believe e.target is what you require
$('body').bind('click', function(e){ e.target // the original target e.target.id // the id of the original target });
If you go to the jQuery in Action website and download the source code, take a look at
- Chapter 4 - dom.2.propagation.html
which deals with event propagation with bubble and capture handlers
Using event.originalTarget
can cause "Permission denied to access property 'XYZ' from a non-chrome context" -error, so i'd recommend using following:
var target = event.target || event.srcElement || event.originalTarget;
event.target
works on Firefox, Opera, Google Chrome and Safari.