1
- // Affichage du contenu HTML de la liste
2
- console . log ( document . getElementById ( "langages" ) . innerHTML ) ;
3
-
4
1
// Modification du contenu HTML de la liste : ajout d'un langage
5
2
document . getElementById ( "langages" ) . innerHTML += '<li id="c">C</li>' ;
6
3
@@ -10,9 +7,13 @@ document.getElementById("langages").innerHTML += '<li id="c">C</li>';
10
7
// Modification du contenu textuel du premier titre
11
8
document . querySelector ( "h1" ) . textContent += " de programmation" ;
12
9
10
+ // Définition de l'attribut "id" du premier titre
11
+ //document.querySelector("h1").setAttribute("id", "titre");
12
+ document . querySelector ( "h1" ) . id = "titre" ;
13
+
13
14
var titre = document . querySelector ( "h1" ) ; // Accès au premier titre h1
14
- titre . classList . add ( "titre" ) ; // Ajout de la classe "titre"
15
15
titre . classList . remove ( "debut" ) ; // Suppression de la classe "titre"
16
+ titre . classList . add ( "titre" ) ; // Ajout de la classe "titre"
16
17
console . log ( titre ) ;
17
18
18
19
// Création d'un noeud textuel
@@ -23,12 +24,12 @@ document.querySelector("h1").appendChild(complement);
23
24
var python = document . createElement ( "li" ) ; // Création d'un élément li
24
25
python . id = "python" ; // Définition de son identifiant
25
26
python . textContent = "Python" ; // Définition de son contenu textuel
26
- document . getElementById ( "langages" ) . appendChild ( python ) ; // Ajout du nouvel élément à la liste
27
+ document . getElementById ( "langages" ) . appendChild ( python ) ; // Insertion du nouvel élément
27
28
28
29
var ruby = document . createElement ( "li" ) ; // Création d'un élément li
29
30
ruby . id = "ruby" ; // Définition de son identifiant
30
31
ruby . appendChild ( document . createTextNode ( "Ruby" ) ) ; // Définition de son contenu textuel
31
- document . getElementById ( "langages" ) . appendChild ( ruby ) ; // Ajout du nouvel élément à la liste
32
+ document . getElementById ( "langages" ) . appendChild ( ruby ) ; // Insertion du nouvel élément
32
33
33
34
var perl = document . createElement ( "li" ) ; // Création d'un élément li
34
35
perl . id = "perl" ; // Définition de son identifiant
0 commit comments