+ 1

AppendChild in Java Script

So, I have a question about the appendChild option in JS. What I am not sure about is this - if I need to add more one paragraph into the code can I use appendChild and how would I do it in that case? Because, if it is used in order to add just one <p> for eg. wouldn't it be easier to just add that one element into the HTML part of the code?

24th Apr 2019, 5:47 PM
Ana Radojicic
Ana Radojicic - avatar
2 Antworten
+ 11
AppendChild is useful for changing your page dinamically. For example, suppose you have a blog and someone put a comment in your page. In javascript you can create a new html element (div,p, etc..) containing the comment text, and add it with AppendChild. For static elements you can put the <p> element in html directly
24th Apr 2019, 6:27 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 1
Thank you very much Javier :) Exactly what I presumed to be, but I wasn't completely sure, so it's a good thing I asked :D
24th Apr 2019, 6:30 PM
Ana Radojicic
Ana Radojicic - avatar