javascript - Get html element in which a mouse click occurred? -


in javascript i'd able determine element in html page in mouse click occurs. note elements not have event listener attached.

basically: cursor somewhere in page, user clicks mouse, capture mouse click event, element in click occurred. possible?

one approach thought of x,y coords of click event, iterate through dom getting positions each element, , finding inner-most element contains click event. sounds bit long-winded though - wondering if there way.

http://www.quirksmode.org nice website explains lot events.

especially question: event properties - html element target of event?.

in internet explorer, can element event object event.srcelement[docs] , in other browsers event.target[docs].

also see "safari bug" workaround in example linked (although don't know whether still exist and/or in version of safari).


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -