I les styles suivants:Quelle est la manière la plus simple d'implémenter le changement de couleur d'arrière-plan mouseover pour les éléments HTML?
a.button {
background-color: orange;
margin: .2cm;
padding: .2cm;
color: black;
font-family: sans-serif;
text-decoration: none;
font-weight: bold;
border: solid #000000;
}
a.buttonMouseover {
background-color: darkGoldenRod;
margin: .2cm;
padding: .2cm;
color: black;
font-family: sans-serif;
text-decoration: none;
font-weight: bold;
border: solid #000000;
}
Et le code javascript suivant (mon premier btw):
function backgroundChangeIn(element){
if (element.className = "a.button"){element.className = "buttonMouseover";}
}
function backgroundChangeOut(element){
if (element.className = "a.buttonMouseover"){element.className = "button";}
}
Et, l'élément suivant qui devrait changer l'arrière-plan sur mouseover:
<a class="button" href="" onmouseover="backgroundChangeIn(this)" onmouseout="backgroundChangeOut(this)">A Button</a>
Ça marche pour moi jusqu'à maintenant. Mais je me demandais s'il y avait un meilleur moyen.
(Désolé tout le code)
Merci pour la vérification orthographique – jjnguy