How to detect when an element over another element in JavaScript?

后端 未结 3 1612
生来不讨喜
生来不讨喜 2021-02-09 01:26

I wrote most of the code... And when the element is \"fully\" over the other element it works. The problem is that I don\'t just want it to be true when the element is \"fully\"

3条回答
  •  你的背包
    2021-02-09 01:58

    When you are attempting is called "collision detection". You need to get the element's COMPUTED offsets and dimensions, not just the element's style declarations.

    This posting may help explain:

    jQuery/JavaScript collision detection

提交回复
热议问题