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

后端 未结 3 937
醉梦人生
醉梦人生 2021-02-09 01:11

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

提交回复
热议问题