+ 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?
2 Answers
+ 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
+ 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