1

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.

Ayoub M.
  • 4,690
  • 10
  • 42
  • 52
  • 1
    Can 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
  • 1
    vanilla 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 Answers2

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