1
- // Affiche du contenu HTML de la liste
1
+ // Affichage du contenu HTML de la liste
2
2
console . log ( document . getElementById ( "langages" ) . innerHTML ) ;
3
3
4
4
// Modification du contenu HTML de la liste : ajout d'un langage
@@ -10,9 +10,6 @@ document.getElementById("langages").innerHTML += '<li id="c">C</li>';
10
10
// Modification du contenu textuel du premier titre
11
11
document . querySelector ( "h1" ) . textContent += " de programmation" ;
12
12
13
- // Modification de la cible du premier lien
14
- document . querySelector ( "a" ) . href = "https://fr.wikipedia.org/wiki/Langage_informatique" ;
15
-
16
13
var titre = document . querySelector ( "h1" ) ; // Accès au premier titre h1
17
14
titre . classList . add ( "titre" ) ; // Ajout de la classe "titre"
18
15
titre . classList . remove ( "debut" ) ; // Suppression de la classe "titre"
@@ -49,4 +46,14 @@ bash.textContent = "bash"; // Définition de son contenu textuel
49
46
document . getElementById ( "langages" ) . replaceChild ( bash , document . getElementById ( "perl" ) ) ;
50
47
51
48
// Suppression de l'élément identifié par "bash"
52
- document . getElementById ( "langages" ) . removeChild ( document . getElementById ( "bash" ) ) ;
49
+ document . getElementById ( "langages" ) . removeChild ( document . getElementById ( "bash" ) ) ;
50
+
51
+ // Exercice 1 : ajout d'un paragraphe contenant un lien
52
+ var p = document . createElement ( "p" ) ;
53
+ var lien = document . createElement ( "a" ) ;
54
+ lien . href = "https://fr.wikipedia.org/wiki/Liste_des_langages_de_programmation" ;
55
+ lien . textContent = "liste" ;
56
+ p . appendChild ( document . createTextNode ( "En voici une " ) ) ;
57
+ p . appendChild ( lien ) ;
58
+ p . appendChild ( document . createTextNode ( " plus complète." ) ) ;
59
+ document . getElementById ( "contenu" ) . appendChild ( p ) ;
0 commit comments