I come to you with an intersting question.
Given position (x,y) in an HTML document, how can you trigger a focus event on an element at that given position.
The problem translates into is there any way to select the element matching a given position?
Sort of like getElementByPosition?
The easiest option is to use
elementFromPoint:Other than that, you can write your own function. This is what first came to mind – I used it a while back when there was some reason for
elementFromPointnot working correctly, I don’t remember what exactly. There are likely to be better ways to do it, but I just tried what I thought of first:You can see it working here.