msElementsFromPoint method
Returns a node list of elements that are “underneath” or intersect a point defined by given x/y coordinates.
![]() |
*object.*msElementsFromPoint(x, y, retVal)
x [in]
Type: Floating-pointy [in]
Type: Floating-pointretVal [out, retval]
Type: NodeListList of nodes that are under or intersect the x/y coordinates.
Type: NodeList
List of nodes that are under or intersect the x/y coordinates.
The list is sorted by z-order, with the first element as the topmost in the order.
The following code sample creates a series of overlapping <div> blocks of varying colors. When you click one, it uses msElementsFromPoint() to get all the elements under the click position and change the background color to gray. Because all elements are returned, including <body> and <html> we only change the background color on the elements with a nodeName of DIV.
var hitTargets = document.msElementsFromPoint(e.clientX, e.clientY); // get elements from point