'svg:line' usually have x1, y1, x2, y2 values.

You can use some basic algebra to calculate the line equation (

and find the point where you want to split the line and create two new line elements.

if you want to split it half way just find the mid point x1 + x2 / 2 and y1 + y2 / 2 and create two new lines and append them to the parent and remove the current.

on click
add new line from start to mid
add new line from mid to end
remove self

Related Query

More Query from same tag