You can indicate on which element the event that the reading was made on, event.target in your callback.
var el = ... el.addEventListener('click', function(event){ if (el !== event.target) return; // Do your stuff. }, false);
Another option is for the handlers to bind to children to prevent the event from being received from the parent handler, but this works more and potentially hides events from things that can actually listen to them above the parent.
Update
Given your sample code, you can do it.
var el = document.getElementById(myObj.id); el.addEventListener("mousedown", myObjDown, false); function myObjDown(event) { if (el !== event.target) return; //do stuff here }
As well as a general note, keep in mind that none if this will work on IE <9, because addEventListener is not supported on them.
loganfsmyth
source share