Expert Developer JavaScript Question: Download Expert JavaScript Developer PDF

What is the disadvantages using innerHTML in JavaScript?

Tweet Share WhatsApp

Answer:

► If you use innerHTML the content is replaced everytime.
► We cannot use like 'appending to innerHTML'.
► Even if we use += like "innerHTML = innerHTML + 'html'" then also the old content is replaced by html.
► If we use innerHTML then the entire innerHTML content is re-parsed and build into elements. Therefore it's much slower.
► The innerHTML doesn't provide validation and therefore we can potentially insert invalid and broken HTML in the document and break it.

Download Expert JavaScript Developer PDF Read All 150 Expert JavaScript Developer Questions
Previous QuestionNext Question
What is the difference between Scripting and Programming?What would "1"+2+3 and 1+2+"3" evaluate to, respectively?