Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

msElementsFromRect method

Returns an node list of elements that are under a rectangle defined by left, top, width, and height.

Internet Explorer 10



object.msElementsFromRect(left, top, width, height, retVal)


left [in]

Type: Floating-point

top [in]

Type: Floating-point

width [in]

Type: Floating-point

height [in]

Type: Floating-point

retVal [out, retval]

Type: NodeList


The following code sample creates a series of overlapping <div> blocks of varying colors. When you click, it uses msElementsFromRec() to get all the elements that are under a 50 pixel rectangular area and changes 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.msElementsFromRect(e.clientX - 25, e.clientY - 25, 50, 50); // captures elements within 50px block



© 2015 Microsoft