I'm not sure of the best way to ask this. I am wanting to append multiple tspan child elements to a single svg text object. I have the following code.
var tspanElement = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
var majNote1 = document.getElementById('majNote1');
function myFunction() {
for(i=1;i<6;i++){
tspanElement.textContent=i;
tspanElement.setAttribute("id",i);
majNote1.appendChild(tspanElement);
}
}
When I run this, It appears that the tspan element is appended only once and not 5 times. Is it possible to reuse the same tspan variable and append it 5 separate times?
You can see an example at http://codepen.io/cmgdesignstudios/pen/VePwog?editors=101