score:3

Accepted answer

Robert's answer already covers how to solve the problem, but here's the D3 way of doing it in addition. In particular, you can use d3.transform() to parse the value of the transform attribute:

var t = d3.transform(d3.select(this).attr("transform"));
console.log(t.translate);

Updated jsfiddle here;

score:3

You can use getAttribute e.g.

this.getAttribute("transform")

or the SVG DOM

this.transform.baseVal.getItem(0).matrix.e + ", " + this.transform.baseVal.getItem(0).matrix.f)

baseVal.numberOfItems gets you how many components there are to the transform and getItem(0).type gets its type i.e. 2 = translate in this case.

This alerts 50, 50 for me on Firefox.


Related Query

More Query from same tag