1
I’m starting in development and I’m on a mission I’m banging my head and I don’t know how to finish.
I need to change tags <i>
for <svg><use></svg>
. That way I stop calling class
and I call upon the id
, as follows code below.
I would like to manipulate by js
. Wherever there is <i class="ico-nomedoicone">
in HTML, be changed to
<svg class="icon"><use xlink:href="icons/icons.svg#icon-nomedoicone"/></svg>
Could someone help me with a code idea?
I thought of something like this...
var i = document.querySelectorAll("i");
for(var i=0;i<=i.length;i++) {
if(i[s].className == "ico-") {
i[i].innerHTML = "<svg class='icon'><use xlink:href='icons/icons.svg#icon-italic'/></svg>";
}
}
There are 2 problems: you use
i
for two different things, and the comparison with==
will not consider partial coincidence of the strings.– bfavaretto