Justin
Justin

Reputation: 77

Change order of SVG elements using javascript

I have an SVG in an HTML doc and would like to make it so that when I click on a rectangle it moves to the top layer. The only thing I found for this was this:

return this.parent.removeElement(this).put(this);

but this doesn't work.

Upvotes: 0

Views: 995

Answers (1)

Robert Longson
Robert Longson

Reputation: 124229

You want insertBefore or appendChild instead of removeElement and put

both insertBefore/appendChild remove the element from where it was when they put somewhere else.

Upvotes: 1

Related Questions