Basically I have 3 squares (3 divs
) and I want to check if one of them intersects another.
I'm using the function.
document.getElementById("container1").getBoundingClientRect();
This is the output using this function
but I do not know how to verify if indeed one element intersects another.
For example, the pink border square intersects the blue border square and vice versa, while the red border div intersects none. Is there any way to verify this intersection?
<div class="container1" id="container1">
</div>
<div class="container2" id="container2">
</div>
<div class="container3" id="container3">
</div>
container1Rect = document.getElementById("container1").getBoundingClientRect();
container2Rect =document.getElementById("container2").getBoundingClientRect();
container3Rect = document.getElementById("container3").getBoundingClientRect();
This is my livecode: