How do we trigger an onClick event on all element inside an imaginary rectangle with a given coordinate in vanilla javascript? Let's assume that we have a rectangle with the following xy coordinate (0,30) (0,40) (30,30) (30,40), and I want to trigger an onClick event on every DOM element with class .select-element inside of that rectangle. How do I do this? Is it possible?
I saw there's this method
Document.elementFromPoint()
But triggering this method for every coordinate seems like a bad idea for performance issues.
https://developer.mozilla.org/en-US/docs/Web/API/Document/elementFromPoint Also, it is relative to the viewport, and doesn't accept a flag for using the absolute coordinate of a DOM element.