I have an SVG in my document and I am adding a character to it using javascript:
var myScene =document.getElementById('myScene'); var useSVG = document.createElement('use'); useSVG.setAttribute('xlink:href','spriteSheet.svg#mySymbol'); useSVG.setAttribute('x','10'); useSVG.setAttribute('y','30'); useSVG.setAttribute('width','10'); useSVG.setAttribute('height','10'); myScene.appendChild(useSVG);
The symbol is not displayed, while the resulting code exactly matches another node written in HTML, which is displayed correctly.
Code shown in the debugger:
<svg id="myScene" width="200px" height="200px"> <use xlink:href="spriteSheet.svg#mySymbol" x="5" y="50" width="10" height="10"></use> <use xlink:href="spriteSheet.svg#mySymbol" x="10" y="30" width="10" height="10"></use> </svg>
bokan source share