Reputation: 328
I'm trying to get the radius of a circle svg element but a error is coming in vs code:
actual code:
const circle = document.getElementById('progress_circle');
const radius = circle.r.baseVal.value;
error:
Property 'r' does not exist on type 'HTMLElement'.js(2339)
I'm using svelte, ts and vs code and I'm also a newbie in web dev.
Upvotes: 0
Views: 620
Reputation: 328
Finally I got to a solution thanks to @aerial301
const circle = document.getElementById('progress_circle');
const radius = +circle.getAttribute('r');
reference: Changing properties of SVG circle in HTML5/JS
Upvotes: 2