2
I’m creating a text svg dynamically, and I want to return the middle line of the two variables when printing. I experimented with the " n" and the "br" but it doesn’t make me.
var text_h_fin = document.createElementNS("http://www.w3.org/2000/svg", "text");
text_h_fin.setAttribute('x',10 );
text_h_fin.setAttribute('y', 20);
text_h_fin.setAttribute('fill', '#000');
text_h_fin.setAttribute('font-size', '14px');
text_h_fin.textContent = "1 linha" + "\n" + "2 linha";
svg.appendChild(text_h_fin);
Can you give a visual example of what you want to do? You want one line under the other?
– Sergio
Yes exactly that, but it’s not working for me. Where I print: text_h_fin.textContent = "1 line" + " n" + "2 line";
– akm
Is this line break always in the same place or dynamic? you’ll have to make different elements for it because there is no line break in the svg text.
– Sergio
Ah ok, so I create another element. Thanks @Sergio
– akm