| <rect x="100"width="100" height="100" fill="red"/> |
| <rect x="200"width="100" height="100" fill="blue"/> |
| function moveSVGElement(element, x, y) { |
| element.setAttribute('x', x); |
| element.setAttribute('y', y); |
| function moveHTMLElement(rect, x, y) { |
| element.style.left = x + 'px'; |
| element.style.top = y + 'px'; |
| var element = document.elementFromPoint(150, 50); |
| if (element instanceof SVGRectElement) |
| moveSVGElement(element, 0, 0); |
| element = document.elementFromPoint(250, 50); |
| if (element instanceof HTMLDivElement) |
| moveHTMLElement(element, 100, 0); |