Let's say I have arrow.svg
file. In my index.js
that is in vanilla JS, I want to appendChild
this to a body. How do I do that?
const theSVGFile = //... read from './arrow.svg'
document.getElementById('some-id').appendChild(theSVGFile);
Let's say I have arrow.svg
file. In my index.js
that is in vanilla JS, I want to appendChild
this to a body. How do I do that?
const theSVGFile = //... read from './arrow.svg'
document.getElementById('some-id').appendChild(theSVGFile);
An example of Zoilo's suggestion which is generally the easiest route but reality is he deserves the credit since he beat me to it.
const daSVGHost = document.createElement("img");
daSVGHost.src = "https://i.stack.imgur.com/BVW9D.jpg"; // SVG HERE
document.getElementById('testerooni').appendChild(daSVGHost);
<div id="testerooni"></div>