GetElement by position?

I am working on an SVG script

have getElementById or getElementsByTagName

but I can not find any method to get elements by position

for example, get elements whose position is x = 10, y = 10.

Is there any way to achieve this?

+4
source share
3 answers
var yourElement = document.elementFromPoint(10, 10); 

Here is a working example that changes the background color of an element at a specified point.

Note that if the specified point is outside the visible area of ​​the document, elementFromPoint will return null .

+8
source

You can try the following:

 $("svg").find("[x='10'][y='10']"); 

It will give all elements with svg that have x = 10 and y = 10.

Job demonstration

+1
source

All Articles