Method to remove an individual element (e.g. path) from within svg document?

2,194 views
Skip to first unread message

Matt

unread,
May 3, 2010, 2:06:06 PM5/3/10
to SVG Web


Hi All,

Loving SVG Web! This is question likely reflects my lack of knowledge
on javascript etc. but what is the javascript approach/method for
removing some element (like a path, circle etc.) occurring within a
svg document? The visual effect would be making the element
invisible, which I can do with attribute settings etc. but I want to
delete the element from the document. I've got the delete an SVG root
figured out, but I need more control if possible.

Somewhat related- Is there a FAQ for this project?

Thanks!

Matt

--
You received this message because you are subscribed to the Google Groups "SVG Web" group.
To post to this group, send email to svg...@googlegroups.com.
To unsubscribe from this group, send email to svg-web+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/svg-web?hl=en.

Bradley Neuberg

unread,
May 3, 2010, 2:20:31 PM5/3/10
to svg...@googlegroups.com
The following should work, if you wanted to get rid of a myCircle node:

myCircle.parentNode.removeChild(myCircle);

basically, get the parent node, then call its removeChild method to remove the node you want to get rid of.

Best,
  Brad

Matt

unread,
May 3, 2010, 2:31:56 PM5/3/10
to SVG Web
Awesome, works perfectly. Thanks for the quick response and keep up
the good work.

cheers,
Matt

On May 3, 2:20 pm, Bradley Neuberg <bradneub...@gmail.com> wrote:
> The following should work, if you wanted to get rid of a myCircle node:
>
> myCircle.parentNode.removeChild(myCircle);
>
> basically, get the parent node, then call its removeChild method to remove
> the node you want to get rid of.
>
> Best,
>   Brad
>
>
>
> On Mon, May 3, 2010 at 11:06 AM, Matt <diapr...@gmail.com> wrote:
>
> > Hi All,
>
> > Loving SVG Web!  This is question likely reflects my lack of knowledge
> > on javascript etc. but what is the javascript approach/method for
> > removing some element (like a path, circle etc.) occurring within a
> > svg document?  The visual effect would be making the element
> > invisible, which I can do with attribute settings etc. but I want to
> > delete the element from the document.  I've got the delete an SVG root
> > figured out, but I need more control if possible.
>
> > Somewhat related- Is there a FAQ for this project?
>
> > Thanks!
>
> > Matt
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "SVG Web" group.
> > To post to this group, send email to svg...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > svg-web+u...@googlegroups.com<svg-web%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/svg-web?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "SVG Web" group.
> To post to this group, send email to svg...@googlegroups.com.
> To unsubscribe from this group, send email to svg-web+u...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/svg-web?hl=en.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages