pros/cons of using `.createElement()` and `append()` vs. `.innerHTML`? code example
Example 1: pros/cons of using `.createElement()` and `append()` vs. `.innerHTML`?
Preserves existing references to DOM elements when appending elements. When you append to (or otherwise modify) innerHTML , all the DOM nodes inside that element have to be re-parsed and recreated. Preserves event handlers attached to any DOM elements. Could be simpler/faster in some cases.
Example 2: pros/cons of using `.createElement()` and `append()` vs. `.innerHTML`?
Preserves existing references to DOM elements when appending elements. When you append to (or otherwise modify) innerHTML , all the DOM nodes inside that element have to be re-parsed and recreated. Preserves event handlers attached to any DOM elements. Could be simpler/faster in some cases.