1

I've got a big element, that includes SVG embed element (external file). I'd like to change its fill colour on a:hover. How would you approach it? It really drives me crazy :)

What I thought should work is:

$("a#title").hover(function() {
$("svg#logo").attr('fill','#f0f');
});
Alex Naspo
  • 2,052
  • 1
  • 20
  • 37
notjust1233971
  • 101
  • 1
  • 9

2 Answers2

0

I have never done this specifically, but it looks like this guy has a jquery plugin you could use located here.

thatidiotguy
  • 8,701
  • 13
  • 60
  • 105
0

What you have there is ok for when the svg is inline in the html. However when it's embedded by reference (embed, object, iframe, img) then the svg is actually a separate document. You can think of this as trying to change attributes in an html document that was referenced by an iframe.

Is the link inside the svg? If so you can put the styles/scripts inside the svg.

Here's an example that changes the fill of an svg shape from the html document (embed, object, iframe).

Erik Dahlström
  • 59,452
  • 12
  • 120
  • 139