In a page that contains an SVG image as an object, we can address individual elements by ID (How to access SVG elements with Javascript):
<object data="myimage.svg" type="image/svg+xml" id="alphasvg"></object>
<script>
var a = document.getElementById("alphasvg");
a.addEventListener("load", function () {
var svgDoc = a.contentDocument; //get the inner DOM of alpha.svg
var delta = svgDoc.getElementById("myelement"); //get the inner element by id
delta.addEventListener("mousedown", function () { alert('hello World!') }, false); //add behaviour
}, false);
</script>
But using svgDoc.getElementById("mygroupelement")
to reference a group element by its ID does not work.
<svg ...>
<path id = "myelement" ...>
<g id="mygroupelement" ...> <.. various path/polyline/etc elements..> </g>
</svg>
So how do you reference a group element in an SVG?
(See also How to get an SVG(+XML) image to interact with the page it is in, where the interaction is in the other direction - from the element to the page.)