Click each shape above to move it to the front.
SVG doesn’t include a concept of z-index, layering, or depth, except that elements that exist later in an SVG document are drawn “on top”. But when designing interactive pieces, we often want shapes that the user has selected / clicked / interacted with to be moved “on top,” to prevent occlusion and ensure visibility.
It’s easy to take an element and simply move it to the bottom of its parent container:
var moveToFront = function() {
this.parentNode.appendChild(this);
}