This html:
<span id="mySpan"><img src="images/picture.png" alt="Some nice alt text" />
Link text</span>
This javascript takes the span containing the image and text, then makes it clickable:
spanVar = document.getElementById("mySpan");
spanVar.addEventListener("click", myEvent, false);
function myEvent(e){
var obj = e.target;
}
If I click on the "Link text," then the obj in myEvent() is the span. If I click on the image, then the obj is the image element! The image itself has no event. So why isn't it always the span that gets passed to the event handler?
This is trimmed down so that it only works in Firefox for the sake of simplicity, by the way.
Also, please feel free to edit my question title if you can formualate it more coherently.