开发者

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:

  1. find out the x and y coordinates of mouse.
  2. Use document.elementFromPoint, add returned element to array.
  3. Hide that element using display:none
  4. Go to 2 until returned element is document.body
  5. Display all hidden elements.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜