Get item below another item in JavaScript
If you 开发者_如何学Gohave a document full of absolute positioned items and you set a document click handler (document.onclick = handler). Is it possible to get all objects that share the mouse position? i.e. two div boxes overlapped, not only the top one
Use the following algorithm:
- find out the x and y coordinates of mouse.
- Use document.elementFromPoint, add returned element to array.
- Hide that element using display:none
- Go to 2 until returned element is document.body
- Display all hidden elements.
精彩评论