4

I am working on SVG script

there are getElementById or getElementsByTagName

but I can't find any method to get elements by position

such as get the elements whose position is x=10,y=10.

is there any way I can achieve this?

kim taeyun
  • 1,837
  • 2
  • 24
  • 49

3 Answers3

9
var yourElement = document.elementFromPoint(10, 10);

Here's a working example that changes the background colour of the element at the specified point.

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

James Allardice
  • 164,175
  • 21
  • 332
  • 312
1

You can try this:

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

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

Working demo

ShankarSangoli
  • 69,612
  • 13
  • 93
  • 124
-1

see this implementation

http://www.webdeveloper.com/forum/archive/index.php/t-50184.html

sushil bharwani
  • 29,685
  • 30
  • 94
  • 128