0

I am having difficulty with using the DOM

I try to run the following code to create a paragraph using JavaScript https://code.sololearn.com/Wahcte6577Mh/?ref=app

12th Sep 2020, 8:34 AM
Graeme Adamson
3 Respostas
+ 5
2 things: 1) you created a new element but did not add it to the body Add this line at the end of the script: document.body.appendChild(para); 2) the code will now throw an error. this will happen because the body has not been initialized yet. you can solve that by moving the entire <script>...</script> below the </body> tag
12th Sep 2020, 8:59 AM
Burey
Burey - avatar
0
You have successfully created paragraph tag and inserted text inside it. When you write console.log(para.innerHTML) ; You will get all idea 💡.
12th Sep 2020, 9:09 AM
Divya Mohan
Divya Mohan - avatar
0
Thanks I got it working with your help
13th Sep 2020, 10:41 AM
Graeme Adamson