Sometimes, we want to simulate a click by using x, y coordinates in JavaScript.
In this article, we’ll look at how to simulate a click by using x, y coordinates in JavaScript.
How to simulate a click by using x, y coordinates in JavaScript?
To simulate a click by using x, y coordinates in JavaScript, we use the elementFromPoint
method.
For instance, we write
document.elementFromPoint(x, y).click();
to select the element at coordinates x
, y
with elementFromPoint
.
Then we call click
to click the element at the coordinates.
Conclusion
To simulate a click by using x, y coordinates in JavaScript, we use the elementFromPoint
method.