How can I change the color of an SVG image on hover?

css, html, javascript, svg

Solution

SVG Files can be modified directly from javascript, i.e. properties of the "image" are accessible from within the DOM.

Look at this post from stack overflow: modify stroke and fill of svg image with javascript

It's important to remember that to do so, you cannot enclose the svg file in the common HTML <img/> tag, use instead the <svg>...</svg> as shown in the post.

EDIT: svg on w3schools

I added a link to w3schools so you can see more properties of the svg object

Have Fun

Problem

Possible Duplicate: Changing SVG image color with javascript I'd like to change the fill of an SVG image when I hover over it. Right now I have a black question mark exported from Illustrator to SVG. I can put on my page with the img tag and it displays fine, however I have no idea how to change the color in code.

Original source

Related problems