Using jQuery .attr() changes "y2" to "75%" , as you see in the script 1 p>
But the hard part is that you want to use transition .
In this case, you should use transform:matrix() :
HTML:
<svg height="300" width="300"> <line class="first" stroke='green' x1='0' y1='50%' x2='100%' y2='25%'/> </svg> <button id="change">change</button>
JQuery
$(document).ready(function(){ $("#button").click(function(){ $(".first").css({ "transform":"matrix(1, 0.6, 0, 1, 0, 0)", "-webkit-transform":"matrix(1, 0.6, 0, 1, 0, 0)", "-ms-transform":"matrix(1, 0.6, 0, 1, 0, 0)" }); }); });
CSS
.first { -webkit-transition-duration: 1s; transition-duration: 1s; }
See working violin 2 .
The tip uses some numbers in matrix() that provide your result.
source share