Possible Duplicate:
JavaScript: Is it better to use innerHTML or (lots of) createElement calls to add a complex div structure?
What should I use instead of .innerHTML? All advice is appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The correct answer is that in certain situations you should use innerHTML, and in other situations you should use appendChild. Here’s when to use innerHTML or appendChild:
Use innerHTML when you’re setting text inside of an HTML tag like an anchor tag, paragraph tag, span, div, or textarea.
Use appendChild() If you’re trying to add new DOM elements inside of another DOM
element.