Accessing an embedded SVG document (<object>)

// source: Sara Soueidan https://vimeo.com/166790778 window.onload=function() { // Get the Object by ID var a = document.getElementById("svgObject"); // Get the SVG Document inside the Object tag var svgDoc = a.contentDocument; // Get one of the SVG items by ID var svgItem = svgDoc.getElementById("svgItem"); // Set the color to something else svgItem.setAttribute("fill", "lime"); }
Get hold of your svg object to start animating it.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.