Setting the 'class' of an SVG element
I could not set the 'class' of an SVG element using the 'className' property in JavaScript.
For example:
var bfyvSVG =
document.createElementNS('http://www.w3.org/2000/svg', 'svg');
bfyvSVG.id = 'bfyvSVG';
bfyvSVG.className = 'bfyvSvg-defs';
One answer is to use 'setAttribute':
bfyvSVG.setAttribute("class","bfyvSvg-defs");
I found the answer on 'stackoverflow.com':
stackoverflow.com/questions/37943006/unable-to-change-class-name-of-svg-element
For an SVG, 'className' means something a little different. I could have used 'className.baseVal'

Comments
Post a Comment