Currently, I am facing an issue where I have two divs positioned at the same x coordinate. I am attempting to retrieve the IDs of both divs using document.elementFromPoint(). However, I am only able to receive the ID of one div.
var elem = document.elementFromPoint(50, 50);
var elem2 = document.elementFromPoint(50, 250);
console.log(elem.id, elem2.id);
#box1,
#box2 {
width: 50px;
height: 50px;
background: greenyellow;
}
#box1 {
position: absolute;
top: 50px;
left: 50px;
}
#box2 {
position: absolute;
top: 50px;
left: 150px;
}
<div id="box1"></div>
<div id="box2"></div>