jim t
jim t

Reputation: 25

Javascript srcElement property on IE9

I have some images in a div object, when mousedown event fired I use n.srcElement to catch the image object.

In Firefox it would be n.target

However IE9 doesn't work on both n.target and n.srcElement because IE9 will return div object rather than image object when use n.target and n.srcElement.

Question is what property can be use on IE9 in order to get image object when click a image in div object.

Upvotes: 1

Views: 374

Answers (1)

peter
peter

Reputation: 22

when you bind div element rather than image and use mouse event, you will get image object if you click on image by using n.target (firefox) or n.srcElement. IE 9 you will need to use window.event.srcElement to get the object you just click.

Upvotes: 1

Related Questions