0

I'm having difficulties selecting a svg element (actually written like img and converted later to svg using jQuery).

The code is:

Html:

<div class="tab-content">
    <div id="personas" class="active">
    <span id="boton_auto"><img class="svg" src="img/auto.svg" /></span>
</div></div>

and jQuery

$(".tab-content div span").find( "svg" ).addClass("activo");

What could be the problem? Thanks in advance!

1 Answers1

1

you missed the dot before svg

or the whole line could be: $(".tab-content .svg").addClass("activo");

edit: I looked at the code that replaces it with an svg. It get's it asynchronously. Are you running your find line before its done? Try adding the line directly after the line $img.replaceWith($svg);

miller345
  • 71
  • 4