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