Categories
JavaScript Answers

How to get element at specified position with JavaScript?

Spread the love

To get element at specified position with JavaScript, we use the elementFromPoint method.

For instance, we write

const elem = document.elementFromPoint(2, 2);

to call document.elementFromPoint with the coordinate of the element to get to return the element at the coordinates.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *