1 Answers

Rahul Roi
Rahul Roi

While you use internal HTML in JavaScript, it can cause some problems -

  • Content is replaced everywhere
  • We cannot use like 'appending to innerHTML'
  • Even if you use +=like 'innerHTML = innerHTML + 'html'' still the old content is replaced by html
  • The entire innerHTML content is re-parsed and builds into elements, therefore its much slower
  • The innerHTML does not provide validation and therefore we can potentially insert valid and broken HTML in the document and break it