document.getElementById("sgun").style.backgroundColor = "#00FA9A";
Je voudrais définir document.getElementById et style.backgroundColor = "# 00FA9A"; en tant que variable, le code n'a pas l'air horrible, et je n'ai pas besoin de copier-coller cela pour chaque élément. Comment faire je fais ça?Javascript définissant un objet dom comme une variable