Reputation: 181
I add a text to an SVG by D3js
var svg = d3.select("body").append("svg");
var t = svg.append("text");
t.append("tspan").attr("class", "span1").text("This is span 1");
t.append("tspan").attr("class", "span2").text("and this is 2");
The SVG element is added and is
<text>
<span class="span1">This is span 1</span>
<span class="span2">and this is 2</span>
</text>
How can I retrieve the whole content of the text element with the span specifiers?
The text is available as
var text = t[0][0].textContent;
but it does contain "This is span1and this is 2" without the span specifiers!
Upvotes: 1
Views: 2287