mercredi 18 novembre 2020

How to set variable of image src and use in javascript function?

So if i have some codes like this

If(sceneA){document.getElementById("divA").src="A.png";}
 If(document.getElementById("divC")=="A.png"){document.getElementById("divB").src="B.png";}//And alot of codes here

How can I use a var to shorten strings like

document.getElementById("divA").src="A.png" document.getElementById("divB").src="B.png"

so i can use them both inside (IF) and {function}

As they have to repeat quite a few times in the codes.

Thanks alot!

Aucun commentaire:

Enregistrer un commentaire