Ruben
Ruben

Reputation: 1091

My SVG doesn't change after changes in the DOM

I'm trying to change the color of a SVGPathElement but it doesn't refresh. I check it gets the new color showing an alert but I don't see any difference. Is it because my SVG is retrieved by AJAX?

var element = document.getElementById(id);
alert(element.getAttribute("stroke"));
element.setAttributeNS(null, "stroke", "#000000");

Thanks in advance

Upvotes: 0

Views: 138

Answers (1)

CodeWizard
CodeWizard

Reputation: 142612

you can try and set the stroke using style:

element.style.stroke='#0000';

Upvotes: 1

Related Questions