There are several reasons why the code you posted here will not work.
First you try to query the DOM of the embedded SVG document, but the query you are executing will only query the DOM on the current page. To access the DOM of an embedded SVG document, you need to do something like the following:
How to access SVG elements using Javascript
The second reason this will not work is because jquery is currently unable to request SVG documents. The reason for this is because the class attribute is encoded as an animated value in the SVG DOM, as opposed to the line in the HTML DOM, which confuses jquery.
For this reason, and since I believe that it will fix other problems that you have with regard to structuring your HTML document, I would recommend that you use the jQuery SVG javascript library: http://keith-wood.name/svg. html
This does a lot of things that seem relevant to your project, including modifying jQuery so that it can query for SVG documents and embed an SVG document in an HTML document using either the native DOM, if supported, or the Adobe plugin. However, be careful, as I found that the SVG DOM plugin is unstable in certain situations in Chromium.
source share