I am trying to load an external SVG document into a simple web page so that I can use it as a basic chloropeth map. However, using <object data=""></object>
in the HTML results in the SVG loading as a subdocument.
Basically I am unable to query the SVG paths by ID using jquery (ex: $('#NY').css("fill", "red")
doesn't do anything). Obviously I can just cut and paste the actual SVG content into the HTML, but I'm curious if there is a way to get the SVG path stuff to load into the HTML document using <object>
or similar.
The HTML:
<object data="/static/metric/img/map_US.svg" type="image/svg+xml">
</object>
Here's a shot of the DOM using the console (notice the SVG stuff is inside a #document
subdocument!):