I have two div elements. Each of them have 450px width and height. How do I check if the first div is overlapping the second div?
I’ve tried to use javascript hittest, but it’s a little bit complicated. Since I’m trying to find out how it actually work, I would like to get started with a simpler code.
I found out that I can use .getClientRects to get the boundary of an element, but I’m not exactly sure how to compare boundaries.
Please advise me!
Something like this for
rect1andrect2retrieved via getBoundingClientRect():Explain: if one or more expressions in the parenthese are
true, there’s no overlapping. If all arefalse, there must be an overlapping.