title: Adding Class to SVG
body: <p>I grabbed an SVG file, <a href="https://upload.wikimedia.org/wikipedia/commons/e/ee/Map_of_New_York_County_Outlines.svg" rel="nofollow noreferrer">a map of NY State</a>, and would like to add classes to various elements (the counties).</p>
  <p>I tried adding a class via javascript. The class was added but visually nothing happened. I tried inserting the class directly. That didn't work. I tried adding a fill to an existing ID  but that didn't do anything.</p>
  <p>The existing code looks something like:</p>
  <pre><code>&lt;polygon id=&quot;St_Lawrence&quot; class=&quot;highlight&quot; points=&quot;404.480957,7.098633 
  </code></pre>
  <p>As said I tried adding a class, adding fill information to the existing ID (St_Lawrence) but that didn't work. However adding a style inline worked (see below)</p>
  <pre><code>&lt;polygon id=&quot;St_Lawrence&quot; style=&quot;fill:#FF0000;&quot; points=&quot;404.480957,7.098633 
  </code></pre>
  <p>That, unfortunately, doesn't really help.</p>
  <p>The basic code is below:</p>
  <pre><code>&lt;svg xmlns:a=&quot;http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/&quot;
       width=&quot;633.475098&quot; height=&quot;475.573242&quot; viewBox=&quot;0 0 633.475098 475.573242&quot;
       style=&quot;overflow:visible;enable-background:new 0 0 633.475098 475.573242&quot; xml:space=&quot;preserve&quot;&gt;
  
  &lt;g id=&quot;Layer_1&quot;&gt;
              &lt;g fill=&quot;#FFFFFF&quot; stroke=&quot;#000000&quot; stroke-width=&quot;0.25&quot;&gt;
                  &lt;polygon id=&quot;St_Lawrence&quot; points=&quot;404.480957,7.098633 404.581543,7.098633 404.581543,7.098633 
                      406.171387,7.099609 406.171387,7.099609 406.218262,7.109375 406.218262,7.109375 406.313965,7.109375 408.001465,7.123047 
                      408.001465,7.123047 408.050293,7.123047 408.050293,7.123047 410.122559,7.138672 410.591309,11.53125 410.591309,11.53125 
  </code></pre>
  <p><strong>EDIT:</strong></p>
  <p>I worked with another SVG file and got classes to work as they should. Don't know  SVG well enough to decipher why this one works while the first one doesn't.</p>