0

Afficher le paragraphe

Bonjour je voudrais afficher le paragraphe que j'ai créé avec document.createElement https://sololearn.com/compiler-playground/WNyP35J8dkMW/?ref=app

28th Nov 2024, 12:26 PM
Diagne Malick
1 Answer
+ 3
Here I just modified a bit to make it workable, What are the issues in your code:- 1>Firstly, you have to add window.onload = () => {} and insert your js code inside it to ensure that all the elements are loaded before any other scripts are executed. 2>Use let, var or const to define a variable. 3>Append the element inside body by `document.body.appendChild(paragraph);` Here is corrected code:- window.onload = () => { let paragraph=document.createElement("p"); paragraph.innerHTML = "Je suis un paragraph"; document.body.appendChild(paragraph); }
28th Nov 2024, 12:42 PM
Gulshan Mahawar
Gulshan Mahawar - avatar