Jump to content
Search Community

Append circle to SVG ID

cbourne test
Moderator Tag

Go to solution Solved by PointC,

Recommended Posts

Does GSAP support appending items to exiting SVG ID's ? I have an SVG documents with an id of "test" and want to append a simple circle to it. 

 

So basically target the "test" id in the svg and append a circle to it. 


 

<div id="scene1-svg" class="chart">
<svg>
...
<rect id="test" class="cls-23" x="55.95" y="63.64" width="85.14" height="60.94"></rect>
...
</svg>
</div>

 

 

Link to comment
Share on other sites

  • 5 months later...

 

Hello @cbourne

 

This is nothing really GSAP related - and we like to keep this forum focussed on GSAP specific questions. Please just keep that in mind.

Maybe @PointC's guide on how to create SVGs dynamically with JS can help get a better general understanding.
 

https://www.motiontricks.com/creating-dynamic-svg-elements-with-javascript/

 

Also here's a codepen demo by somebody else showcasing how to add text to an existing SVG.

See the Pen XYXNwq by kaykay (@kaykay) on CodePen


This could then result in something like this for the earlier example within this thread. I hope this will help.

See the Pen rNozJOm by akapowl (@akapowl) on CodePen

 

If you want the text to appear inside the appended blue rect, you will probably need to just position it properly, as I don't think you can nest it inside the rect. Something like this maybe.

See the Pen vYvJdxb by akapowl (@akapowl) on CodePen

 

https://stackoverflow.com/questions/6725288/svg-text-inside-rect

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...