LearnFrenzy
Sign in Take a free test

DOM Manipulation · DOM Manipulation MCQ · Question 14

innerHTML += and listeners Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 14 Back to Exercise

What is the hidden cost of list.innerHTML += "<li>New</li>"?

  • A Every existing child is re-parsed and re-created, so their listeners and state are lost Correct
  • B Nothing – it only adds one element
  • C It throws in strict mode
  • D It adds the item at the start
Correct Answer: Option A

It reads the HTML as a string, appends to it and parses everything again. Use append or insertAdjacentHTML.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links