SVG has a wonderful symbol
/ use
system where one can define e.g. icons just one, then drop them around the SVG by using use
. Only I don't get it to work from JavaScript.
See this fiddle.
The programmatically created use
nodes become visible in the browser's DOM, and are identical to the statically created ones. But only the static ones are visible.
Can you explain what's going on?
symbol
is very similar to defs
, but allows the viewBox
to be defined next to the symbol, thus making scaling of the entries easier and causes cleaner code. I'm okay working with defs
but I faced similar issues there, too.
Note: My JavaScript is on the HTML side, not within SVG. I would like to have it that way.