+ 2

How to change + icon to - icon when span is clicked?

https://code.sololearn.com/W4Y3LcW4MTVD/?ref=app

29th Jan 2022, 5:51 AM
Tech
2 Respuestas
+ 3
const span=document.getElementsByTagName("span"); for(let i=0; i<span.length; i++){ span[i].onclick=function (){ const content=document.querySelectorAll(".content"); for(let j=0; j<content.length; j++){ if(j===i) content[j].classList.toggle("show") else content[j].classList.add("show") } } } // in addition will be needed to set the start positions of the spans for example using css
29th Jan 2022, 8:41 AM
JaScript
JaScript - avatar
+ 1
JaScript thanks but my problem is the - icon I want + icon be replaced with -icon while toggling spans
29th Jan 2022, 8:46 AM
Tech