Modifier styles CSS avec JS
Bonjour,
n'étant pas du tout javascript, je bloque sur un problème de débutant...
Ma page HTML possède un bouton sur lequel j'aimerais affecter la fonction suivante, déclarée dans mon header :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| function selection(thingId)
{
var targetElement;
targetElement = document.getElementById(thingId) ;
if (targetElement.style.font-weight == "bold")
{
targetElement.style.font-weight = "normal" ;
} else if (targetElement.style.font-weight == "normal") {
targetElement.style.font-weight = "bold" ;
}
} |
Dans le body, voici mon bouton :
Code:
<p id="boutonfev" style="font-weight:normal;"><a href="javascript:selection('boutonfev');">texte de mon bouton</a></p>
Pourtant cela ne fonctionne pas, j'ai beau cliquer sur mon bouton son style font-weight ne change jamais.
Merci anticipé pour vos pistes !