如何确定某个位置上是否有任何元素? [英] How can I find whether there are any elements at a certain position?

查看:110
本文介绍了如何确定某个位置上是否有任何元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个较大的div上的不同位置有一个具有相同类的div集合.有没有一种使用jQuery的方法来确定是否有div与屏幕上的给定位置重叠?

I have a collection of divs with the same class at various positions on a larger div. Is there a way, using jQuery, to determine if any divs are overlapping a given position on the screen?

推荐答案

阅读有关document.elementFromPoint()的部分:

Read the section on document.elementFromPoint(): http://www.quirksmode.org/blog/archives/2010/06/more_ie9_goodne.html

您可以使用它在该位置找到最顶部"元素.隐藏该元素,然后再次询问.如果您再点击一次,则2个div在该位置重叠.

You can use this to find the "top-most" element at that location. Hide that element, then ask again. If you get another hit, then the 2 divs overlap at that position.

这篇关于如何确定某个位置上是否有任何元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆