I'm programmatically adding an <embed>
tag to my HTML document:
var e = document.createElement('embed');
e.src = "some-image.svg";
e.type = "image/svg+xml";
document.body.appendChild(e);
This works fine, and the SVG element displays as expected. However, I want to manipulate the SVG elements with JavaScript, and attempting to do so immediately after adding the element to the DOM fails, as the content hasn't loaded yet.
How can I do this. Note that I want to do this without jQuery so please don't point to the jQuery API.