The SVGAnimatedString interface represents string attributes which can be animated from each SVG declaration. You need to create SVG attribute before doing anything else, everything should be declared inside this.
SVGAnimatedString
MDN Reference
The animVal read-only property of the SVGAnimatedString interface is a string representing the animated value of the reflected attribute.
animVal
The baseVal property of the SVGAnimatedString interface gets or sets the base value of the given attribute.
baseVal