Is there a way to select an element using it's (x,y) coordinates with jquery or in any other way. other than going through all the page elements and comparing coordinates.
Asked
Active
Viewed 2,260 times
1
-
1Can you be a little more specific? The answer is no - sort of. However, depending on what you want to do, there might be better ways around that. Getting the coordinates of a clicked element... ...or getting the coordinates of a known element, or moving a known element to specific coordinates, et cetera. – Norguard Oct 18 '11 at 23:34
-
1vanilla javascript has an elementFromPoint() API. The problem is, support for this seems to vary between browsers. Check this page where someone has provided a consistent way to do it using jQuery -- http://www.zehnet.de/2010/11/19/document-elementfrompoint-a-jquery-solution/ – carpii Oct 18 '11 at 23:36
2 Answers
8
You need to use document.elementFromPoint()
. Note that this is not jQuery specific. Reference and compatibility guidance on quirksmode.

N Rohler
- 4,595
- 24
- 20
2
Try this, works cross browser

FloydThreepwood
- 1,587
- 14
- 24
-
Note that browser compatibility issues are only present in Opera 10.10 and Safari 4, both antiquated versions at this point. – N Rohler Oct 18 '11 at 23:40
-
Depends on your target audience. Safari 4 will be present on legace iPhones. – FloydThreepwood Feb 24 '12 at 23:48