JS how to change SVG element?



  • Good evening!

    Can you tell me how to change the SVG element? In my case, it's tspan, like I need to raise it up.

        <svg width="100%" height="100%">      
    <text id="AAA" stroke="#000000" stroke-width="0.5" font-size="50" transform="rotate(-5 20,40)">
    <tspan id="AAA" x="20%" y="45%" style="font-family: Pompadur; stroke:#000000;">ТЕКСТ</tspan>
    


  • You can change the coordinates of this element you have described through. x="20%" y="45%using the method setAttribute() :

    document.querySelector('tspan').setAttribute('y','15%');
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2