I have the following code to create an SVG image of a needle( something like the needle in a speedometer).
<circle class="needle-center" cx="200" cy="200" r="5"></circle>
<path class="needle" d="M 195 198 L 200 100 L 205 202 "></path>
<button id="test">Click Here</button>
On clicking the button i'm trying to rotate the svg image using Jquery function.
$("#test").click(function () {
$('.needle').css(" transform-origin", "bottom");
$('.needle').attr("transform", "rotate(45)");
});
Instead of rotating it is just randomly moving away. How can i fix this? Is there a better way to animate svg? (i'm new to SVG)
Before clicking:
After clicking: