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
3 odpowiedzi
+ 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
0
You have successfully created paragraph tag and inserted text inside it.
When you write
console.log(para.innerHTML) ;
You will get all idea 💡.
0
Thanks I got it working with your help