textDecoration en JavaScript
Bonjour
voici mon code simplifi�.
id nb_chapitre est bien soulign� gr�ce � style.textDecoration="underline" mais nb_ligne mis � style.textDecoration="none" laisse le text soulign� malgr� que en mode d�bug style.textDecoration est bien �gale � "none"
test� sous win10/chrome.
J'ai test� en passant par du CSS c'est pareil m�me en rajoutant !important
je ne vois pas ou je me suis tromp�.
En vous remerciant pour votre aide
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| <!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function test() {
m="chapitre doit etre souligné : ok";
m1="ligne ne doit pas etre souligné: ko";
var div_list = document.getElementById('list1'); // récupération de la liste
var div_chapitre = document.createElement("div"); // on cré un nouveau noeud item de liste
div_chapitre.setAttribute("id","nb_chapitre");
var text_chapitre = document.createTextNode(m); // on cré un noeud texte
div_chapitre.appendChild(text_chapitre); // on attache le noeud texte au noeud item de liste
div_list.appendChild(div_chapitre);
var div_chapitre1 = document.getElementById('nb_chapitre');
var div_lignes = document.createElement("div");
div_lignes.setAttribute("id","nb_lignes");
div_chapitre1.appendChild(div_lignes);
document.getElementById('nb_chapitre').style.textDecoration="underline";
// plus tard dans une autre fonction
var div_lignes = document.getElementById('nb_lignes'); // récupération de la liste
var div_ligne = document.createElement("div"); // on cré un nouveau noeud item de liste
div_ligne.setAttribute("id","nb_ligne");
var oText = document.createTextNode(m1); // on cré un noeud texte
div_ligne.appendChild(oText);
div_lignes.appendChild(div_ligne); // on attache le noeud texte au noeud item de liste
document.getElementById('nb_ligne').style.textDecoration="none";
}
</script>
<form>
<input type=checkbox onClick='test()'>bouton<br>
<div id='list1'>vide</div>
</form>
</body>
</html> |