JavaScript HTML获取指定位置的元素

var element = document.elementFromPoint(x, y);

在给定的坐标点处的顶端 Element(译者注:如果元素层叠的话,返回最上层的元素)。

If the element at the specified point belongs to another document (for example, an iframe’s subdocument), the subdocument’s parent element is returned (the iframe itself). If the element at the given point is anonymous or XBL generated content, such as a textbox’s scroll bars, then the first non-anonymous ancestor element (for example, the textbox) is returned.

发布了231 篇原创文章 · 获赞 13 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/LU_ZHAO/article/details/105040382
今日推荐