by clemens (04.10.2021)

Find all Elements at Mouse Position in Javascript

tl;dr

Get an array of all elements at the specified coordinates, relative to the viewport, using Document.elementsFromPoint().

E.g. from an event:

document.addEventListener("mousedown", event => {
    document.elementsFromPoint(event.clientX, event.clientY)
        .forEach(el => el.matches(".some-selector"));
});